Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

java - how to write log file by using custom appender by using log4j2

I need to write a log file for one functionality by using log4j2. In the same module already one log file is being written by using RollingFileAppender.

Both logs are different, and I need different logs file for each, but both are in the same package in Java. How can I do this?

For example, existing log file handles about developer log, now I want to make log file for request received.

This is the log4j2 xml for the existing log:

<RollingFile name="File" fileName="log/CRUD.log" 
      filePattern="log/CRUD.%d{yyyy-MM-dd}_%i.Logs.gz">
    <Layout type="PatternLayout">
         <Pattern>%d{[MM.dd.yyyy] | [HH:mm:ss]|}%level{FATAL=[FATAL],ERROR=[ERROR], WARN=[WARN], INFO=[INFO], DEBUG=[DEBUG],  TRACE=[TRACE]}|[%X{sessionID}]|[%F]|[%M]|[%L]|%m%throwable%n</Pattern>
    </Layout>
    <Policies>
        <SizeBasedTriggeringPolicy size="100 MB" /> 
    </Policies>
    <DefaultRolloverStrategy fileIndex="max" max="50">
    </DefaultRolloverStrategy>   
</RollingFile>

How do I make another log file in the same package?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...