This topic describes how to use LogHub Log4j Appenders or Logtail to collect Log4j logs.
Background information
Log4j is an open source project of Apache. Log4j allows you to specify the level,
output destination, and output format of logs. The log levels are ERROR, WARN, INFO,
and DEBUG. The output destination determines whether logs are displayed in consoles
or files. The output format determines the format of logs that are displayed. In this
topic, the default configuration of Log4j is used. Default configuration:
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss:SSS zzz} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com.foo.Bar" level="trace">
<AppenderRef ref="Console"/>
</Logger>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
The following example shows a Log4j log:
2013-12-25 19:57:06,954 [10.10.10.10] WARN impl.PermanentTairDaoImpl - Fail to Read Permanent Tair,key:e:470217319319741_1,result:com.example.tair.Result@172e3ebc[rc=code=-1, msg=connection error or timeout,value=,flag=0]
Use LogHub Log4j Appenders to collect Log4j logs
For more information about how to use LogHub Log4j Appenders to collect Log4j logs, see Log4j Appender.
Use Logtail to collect Log4j logs
Log Service provides configuration wizards to help you create Logtail configurations. The following example describes how to collect Log4j logs in full regex mode.