I am working with Java Web App {Servlet + JSP + Tomcat} and having one log management for the info and error logs.
Now I want to add some actual data log functionality with different path name and property values. How can I achieve this in Java ?
Existing Log Property
<Configuration status="ALL" name="Logger" packages="">
<Properties>
<Property name="baseDir">D:\\Log\\</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" append="true" fileName="${baseDir}/Log.log" filePattern="${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout pattern="%d{dd/MM/YYYY HH:mm:ss.SSS} [%t] %-5level %logger{36} %msg %n"/>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="30 MB" />
</Policies>
<!-- Create 5 archives for the same date if the log file size exceeds 30MB -->
<!-- Deletes the logs which are older than 60 days from the current date -->
<DefaultRolloverStrategy max="5">
<Delete basePath="${baseDir}" maxDepth="2">
<IfFileName glob="*/app-*.log.gz">
<IfLastModified age="60d" />
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<Root level="ALL">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
Java
public class Logj {
static Logger objLogger = LogManager.getLogger(Logj.class);
public static void doLog(Exception objException){
objLogger.error("StackTrace - "+objException.fillInStackTrace());
}
public static void doActivityLog(String strActivityMessage){
objLogger.info(" Activity - "+strActivityMessage);
}
}
I need same functionality to be execute for the new requirement
Will it support to add multiple Properties to add different directory path and adding multiple Appenders with different names ?
Thank in advance!!
您需要在properties标记中添加另一个具有不同路径的属性,并添加另一个滚动文件附加程序,并在根级别引用该附加程序,这将创建两个日志。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.