java - Log4J is not archiving logs properly -
I am trying to configure a log4j for my application. I want to roll it everyday, which means that I want to create a new text file with the log and archive the old ones. For some reason, my loggers remove old logs and write them without collecting old logs.
When I changed it to roll every minute, it is not a problem. Every minute it archives my log and writes new.
When I change it to roll every hour, then in the case of rolling the same problem daily, it just erases old logs without archiving them.
Can anyone tell me in the right direction? Thank you
log4j.rootlogger = debug, a1 log4j.logger.org.hibernate = error log4j.appender.a1 = org.apache.log4j.DailyRollingFileAppender log4j.appender.A1.File = C: Desktop \\ MyLogs \\ data.log # log4j.appender.a1.DatePattern = '.' Yyyy-MM-dd minutes each # log4j.appender.A1.DatePattern = '.' Yyyy-MM-HD-HH-MM # Hour4 log4j.appender.A1.DatePattern = '.' Yyyy-MM-dd-HH log4j.appender.A1.layout = org.apache.log4j.PatternLayout log 4 j.appender.A1.layout .Commonparation =% d {MM / dd / yyyy HH: mm: ss} |% -5p |% C:% m% n
I ran a weblogic server on my local machine I am on whom I am testing my application. It appears that every time you make a change in a log4j property file, you need to restart the server to take effect. I was republishing the project without restarting the server
The above logger configuration is working fine for both minute and hour logging. I'll test logging tonight, but I'm sure everything will be in order.
If someone is interested, then my Maven dependency is for Lojor:
& lt; Dependency & gt; & Lt; Group & gt; Org.slf4j & lt; / Group & gt; & Lt; ArtifactId & gt; Slf4j-api & lt; / ArtifactId> & Lt; Version & gt; 1.4.2 & lt; / Edition & gt; & Lt; / Dependencies & gt; & Lt; Dependency & gt; & Lt; Group & gt; Org.slf4j & lt; / Group & gt; & Lt; ArtifactId & gt; Slf4j-log4j12 & lt; / ArtifactId> & Lt; Version & gt; 1.4.2 & lt; / Edition & gt; & Lt; / Dependencies & gt; & Lt; Dependency & gt; & Lt; Group & gt; Org.apache.logging.log4j & lt; / Group & gt; & Lt; ArtifactId & gt; Log4j-slf4j-implant & lt; / ArtifactId> & Lt; Version & gt; 2.1 & lt; / Edition & gt; & Lt; / Dependencies & gt; & Lt; Dependency & gt; & Lt; Group & gt; Org.apache.logging.log4j & lt; / Group & gt; & Lt; ArtifactId & gt; Log4j core & lt; / ArtifactId> & Lt; Version & gt; 2.1 & lt; / Edition & gt; & Lt; / Dependencies & gt;
Comments
Post a Comment