Parsley Development Guide 15 log Configuration

Source: Internet
Author: User
15 log Configuration

Because the log configuration changes frequently (depending on the deployment scenario and the developer's personal settings), it is often stored in an external xml configuration file. Therefore, parsley provides an optional extension and a set of XML tags for log configuration.

For flex applications, XML labels can be used to build standard flex logtargets. Use the spicelib logging framework to create logs for FLASH application parsley to contain a set of independent labels. In the last section, we will demonstrate how to configure log output within the parsley framework class.

This function does not belong to parsley core. Extensions can be downloaded from the parsley download page. Just add the downloaded swcs to your classpath.

15.1 flex log Configuration

If you want to use the flex logging API, you have two options: You can use the built-in mxml tag to configure logtargets in mxml -- in this case, you do not need to integrate parsley. Use the flex logging API to view flex livedocs.

If you like to use external XML file configuration logs, you can use a parsley extension xml tag to create logtargets:

<Objects

Xmlns = "http://www.spicefactory.org/parsley"

Xmlns: log = "http://www.spicefactory.org/parsley/flex/logging"

Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

Xsi: schemalocation = "http://www.spicefactory.org/parsley

Http://www.spicefactory.org/parsley/schema/2.3/parsley-core.xsd

Http://www.spicefactory.org/parsley/flex/logging

Http://www.spicefactory.org/parsley/schema/2.3/parsley-logging-flex.xsd"

>

<Log: target level = "error">

<Log: Filter> org. spicefactory. * </log: Filter>

</Log: Target>

<Log: target level = "debug">

<Log: Filter> com. Bookstore. * </log: Filter>

<Log: Filter> com. mycompany. util. * </log: Filter>

</Log: Target>

<! -- Other object definitions -->

</Objects>

In the preceding example, you can only view the internal error logs of the spicefactory framework class and debug logs of your own application class.

The default target class for tag creation is a TraceTarget. You can explicitly declare other target types:

<Log: target level = "debug" type = "com. Bookstore. util. customlogtarget">

<Log: Filter> com. Bookstore. * </log: Filter>

</Log: Target>

Because this is an extension, you must initialize it explicitly before using xmlcontextbuilder:

Flexloggingxmlsupport. initialize ();

15.2 flash log Configuration

....

15.3 parsley framework log Configuration

Finally, you may want to see the output of parsleys (and spicelibs) logs for debugging.

You can use logcontext to obtain a logger Proxy:

Logcontext. getlogger (myclass );

You can even use the proxies logger in your own code, which is not very useful for building applications, because they are either flex or flash applications, therefore, you can simply decide which log APIs to use.

Finally, the actual proxy must be initialized, depending on the environment.

Set proxy for flex logging API

In most cases, the agent is automatically initialized. If you use the static entry method of the flexcontextbuilder class or the xml configuration extension label displayed in the 15.1 flex log configuration.

If you are not using these two methods, you must manually initialize the Proxy:

Logcontext. Factory = new flexlogfactory ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.