directory, and you can make it yourself (you need to rely on the Log4cplus library).
Loggingserver use is as follows:
./loggingserver 9000 Log4cplus.properties
9000 indicates the listener port number (no address required, default listener native address)
Log4cplus.properties is a log4cplus configuration file, the same as the normal Log4cplus profile, Loggingserver receives the log from each socket and writes it to the file according to the profile information.
The following is an example of
The simple configuration of log4j makes it more and more applications: The log4j configuration file realizes output to console, file, rollback file, send log mail, output to database log table, custom label and so on. Choose its one or two use is enough, Log4j.rootlogger=debug,console,a1,im log4j.addivity.org.apache=true # applied to the console Log4j.appender.console=org.apache.log4j.consoleappender Log4j.appender.threshold=debug Log4j.appender.console.target=system.out Log4j.appender.console.l
, which outputs the log information to the standard output (console). Based on this example, the following parsing is carried out:# Rootloggerlog4j.rootlogger=debug, stdout# stdout Appenderlog4j.appender.stdout=org.apache.log4j.consoleappender# stdout Appender layoutlog4j.appender.stdout.layout= org.apache.log4j.patternlayoutlog4j.appender.stdout.layout.conversionpattern=%-4r [%t]%-5p%c%x-%m%nLog4j is a configuration prefix, each line of valid configu
(1)14P (2)24P (3)3EndP (4)4
Execute the p (2) Statement 2: cout
In the same case as above, when Statement 3 is executed, p (0) is also called. the execution of p (1) can continue only after p (0) is executed ).
5. start to call P (0). The executed statements include: 1.
4P (0)04P (1)14P (2)24P (3)3EndP (4)4
Because w = 0 does not meet statement 1, jump directly to statement 5 and 6, so that p (0) is executed completely, and p (0) needs to perform the "Out Stack" operation.
6. the statements
).
5. Start to call P (0). The executed statements include: 1.
4P (0)04P (1)14P (2)24P (3)3EndP (4)4
Because w = 0 does not meet Statement 1, Jump directly to Statement 5 and 6, so that p (0) is executed completely, and p (0) needs to perform the "out stack" operation.
6. The statements executed at this time are: 4
4P (1)14P (2)24P (3)3EndP (4)4
Since p (0) execution is complete, and p (0) is 4 in Square a, so continue to execute p (1) Statement 4: p (W-1 ); because the w value in p (1) Squar
only the log information for the day:Log4j.appender.a2=org.apache.log4j.dailyrollingfileappenderLog4j.appender.a2.file=dglogLog4j.appender.a2.datepattern= '. ' Yyyy-mm-ddLog4j.appender.a2.layout=org.apache.log4j.patternlayoutlog4j.appender.a2.layout.conversionpattern=%5r%-5p%c{2}-%m%n
2.2.4. Org.apache.log4j.RollingFileAppender
A new file is generated when the file size reaches the specified size.Log4j.appender.r=org.apache.log4j.rollingfileappende
=org.apache.log4j.patternlayoutlog4j.appender.a1.layout.conversionpattern=%-5p [%t]%37c%3x-%m%n#A2--Print to file Daolog--dedicated to DAO layer serviceLog4j.appender.a2=org.apache.log4j.dailyrollingfileappenderLog4j.appender.a2.file=daologLog4j.appender.a2.datepattern= '. ' Yyyy-mm-ddLog4j.appender.a2.layout=org.apache.log4j.patternlayoutLOG4J.APPENDER.A2.LAYOUT.CONVERSIONPATTERN=[%-5P]%d{yyyy-mm-dd Hh:mm:
=org.apache.log4j.consoleappenderLog4j.appender.a1.layout=org.apache.log4j.patternlayoutlog4j.appender.a1.layout.conversionpattern=%-5p [%t]%37c%3x-%m%n#A2--Print to file Daolog--dedicated to DAO layer serviceLog4j.appender.a2=org.apache.log4j.dailyrollingfileappenderLog4j.appender.a2.file=daologLog4j.appender.a2.datepattern= '. ' Yyyy-mm-ddLog4j.appender.a2.layout=org.apache.log4j.patternlayoutLOG4J.APPENDER.A2.LAYOUT.CONVERSIONPATTERN=[%-
Log4j.appender.a1=org.apache.log4j.consoleappender
Log4j.appender.a1.layout=org.apache.log4j.patternlayout
LOG4J.APPENDER.A1.LAYOUT.CONVERSIONPATTERN=[%-5P]%d{yyyy-mm-dd HH:mm:ss. SSS} [%t][%x]%c{8}@ (%f:%l):%m%n
# Set the output location, where the Tomcat directory is set under the logs, the file name is All.log.
Log4j.appender.a2=org.apache.log4j.rollingfileappender
Log4j.appender.a2.file=${catalina.home}/logs/all.log
log4j.appender.a2.maxfilesiz
When we use log4j, we always show:
Java code Log4j:warn No Appenders could is found for logger (org.apache.ibatis.logging.LogFactory). Log4j:warn Initialize the log4j system properly.
This problem is because our Log4j.properties file configuration is not complete enough, so we configured it so that it won't happen again.
The log4j.properties is not fully configured as follows:
Java code log4j.rootlogger=debug, stdout Log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.st Dout.l
There is a lot to say about log4j output logs by level and output to different files according to level, the most log4j.properties settings on the web are like this[Java]View PlainCopy
Log4j.rootlogger=info,stdout,info,debug,error
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
LOG4J.APPENDER.STDOUT.LAYOUT.CONVERSIONPATTERN=[%-5P] [%d{hh:mm:ss}]%c-%m%n
Log4j.logger.info=
Briefly:Add logger log output, below is the configuration information for the memoSteps:1. Add dependency in Maven's Porn.xml file as follows[HTML]View Plaincopy
dependency>
groupId>org.slf4jgroupId>
artifactid>slf4j-log4j12artifactid>
version>1.7.2version>
Dependency>
You will then add three packages,2. Then add log4j.properties under the projectThe project path is as follows,Log4j.properties[HTML]View Plaincopy
#config Root Logger
Log4j.rootlogger = Info,sys
., deny first, then allow) just the opposite of the run order. The post-write condition will be run first, for example: Log4cplus.appender.append_1.filters.1=log4cplus::spi:: Loglevelmatchfilterlog4cplus.appender.append_1.filters.1.logleveltomatch=tracelog4cplus.appender.append_1. FILTERS.1.ACCEPTONMATCH=TRUE#LOG4CPLUS.APPENDER.APPEND_1.FILTERS.2=LOG4CPLUS::SPI::D enyallfilter The Filters.2 filter is run first. Close all filters. Then run filters.1, matching only trace information. 1.3. Settin
Iptable's responsibility chain (i.e., deny first, then allow) but the execution order is reversed, and the post-write condition is executed first, such as:Log4cplus.appender.append_1.filters.1=log4cplus::spi::loglevelmatchfilterlog4cplus.appender.append_1. filters.1.logleveltomatch=tracelog4cplus.appender.append_1.filters.1.acceptonmatch=true# LOG4CPLUS.APPENDER.APPEND_1.FILTERS.2=LOG4CPLUS::SPI::D enyallfilterThe Filters.2 filter is executed first, all filters are turned off, and then the filt
the class #%l corresponding output of the log, corresponding to the line number of the class corresponding to the output of the log Log4j.appender.rootAppender.lay Out.
Conversionpattern=%d{yyyy-mm-dd hh:mm:sss}%-5p [%t]%m (%.30c.%l)%n #自定义logger LOG4J.LOGGER.COM.UCWEB.PROFILE=WARN,PERFMT #Print only the log to the current file switch, not recursively print to the parent logger #这个开关默认是开启 (recursive log to the parent logger), strongly recommend that
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.