JBoss5. Introduction to configuring log4j under X

Recently, log4j was configured under JBoss. The directories of various versions of JBoss and the file names of JBoss and log4j integration changed every time. In JBoss 5 Log4j is configured under X XML file, but the configuration does not take effect. If you do not specify the configuration file of log4j in the project, you'd better use the configuration file provided by JBoss, which is called jboss-log4j xml。 The file is in the directory of JBoss container: ${jboss_home} \ server \ default \ conf. Here are some basic modifications and comments based on the log4j default configuration:

1. Several output modes of log4j

org. apache. log4j. Consoleappender (console) org.apache.log4j.fileappender (file) org.apache.log4j.dailyrollingfileappender (generate a log file every day) org.apache.log4j.writerappender (send log information to any specified location in stream format)

2. Priority of logging

Priority from high to low: off > fat > error > warn > info > debug > all. Log4j it is recommended to use fat, error, warn, info and debug. You can configure the level in < param name = "threshold" value = "error" / > threshold is a global filter, and the level lower than its setting will not be displayed.

3. Do you want to save the previous log after restarting the JBoss service

< param name = "append" value = "true" / >, when set to true, the current log will not disappear after jboos is restarted, that is, a new log will be added to the original log.

4. Log output format

%C the full name of the class to which the output belongs can be modified to% C {num}. Num indicates the output range, such as "org. Apache. Elazen. Classname",% C {2} will output elazen Classname% D output log time in the format of% d {yyyy MM DD HH: mm: SS, SSS}. The format can be specified, such as% d {HH: mm: SS}% l output log event location, including category name, thread, number of lines in the code% N line feed% m output code specified information, such as info ("message"), output message% P output priority, i.e. fatal, Error and other% R output the number of milliseconds spent from Startup to displaying the log information% t output the name of the thread that generated the log event

5. Configuration of category

Category specifies the level of the log output by the class under the package starting with. For example:

As can be seen from the above, the project is based on COM In all classes at the beginning of the Liang package, all debug level logs can be output to file.

Note: a reference of appender ref = file is defined, but if you also configure the reference of appender ref = file under root, the log output to file will be repeated. I have encountered similar problems.

summary

The above is about JBoss 5 X to configure the log4j method. I hope it will be helpful to you. Friends who are just interested can continue to refer to this site: talking about the two configuration containers of spring, why we need to make three webpack configuration files, Java spring annotation configuration bean instance code analysis, etc. thank you for reading

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>