[ 
https://issues.apache.org/jira/browse/LOG4J2-3385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17486465#comment-17486465
 ] 

Jitin Dominic commented on LOG4J2-3385:
---------------------------------------

[~rgoers] 

Could you please confirm if rootLogger needs to be configured all the  time? I 
was actually creating another log4j2.properties file with a console and 
RollingFile appender:
{code:java}
appenders = console, rolling

appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n

appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{ABSOLUTE} %5p %c - %m%n
appender.rolling.fileName = /home/jd/Desktop/App.log
appender.rolling.filePattern = /home/jd/Desktop/App-%d{yyyy-MM-dd -HH-mm}.log
appender.rolling.append = false
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy

loggers = rolling

logger.rolling.name = org.apache.logging.log4j.core.appender.RollingFileAppender
logger.rolling.level = debug
#logger.rolling.appenderRefs = rolling
#logger.rolling.appenderRef.rolling.ref = RollingFile

rootLogger.level = debug
rootLogger.appenderRefs = stdout, rolling
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.rolling.ref = RollingFile
 {code}
 

I expected logger itself might take care of output in the file but I had to 
explicitly mention _rootLogger_ for the file also. Any idea why is it so or am 
I missing something in the concept?

 

 

> New log file on each run
> ------------------------
>
>                 Key: LOG4J2-3385
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3385
>             Project: Log4j 2
>          Issue Type: Question
>            Reporter: Jitin Dominic
>            Priority: Major
>
> I'm using the latest (v2.17.1) log4j2 dependencies in my grails 2.5.4 
> application. Following are the dependencies used:
>  * log4j-api
>  * log4j-core
>  * log4j-1.2-api
>  * log4j-slf4j-impl
>  
> I'm trying to configure the _log4j2.properties_ in a way to create a new file 
> based on date and time on each application run.
> But when I run it, only the application.log file gets created. There's no 
> date and time in the file name. And also, nothing is logged inside the file; 
> it's empty.  Any idea what I might be configuring wrong.
> Here's my log4j2.properties file:
> {code:java}
> appender.rolling.type = RollingFile 
> appender.rolling.name = RollingFile 
> appender.rolling.fileName = /home/jd/application.log 
> appender.rolling.filePattern = /home/jd/application.%d{dd-MMM-hh}.log 
> appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern 
> = %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n 
> appender.rolling.policies.type = Policies appender.rolling.policies.time.type 
> = TimeBasedTriggeringPolicy appender.rolling.policies.time.interval = 1 
> appender.rolling.policies.time.modulate = true 
> appender.rolling.strategy.type = DefaultRolloverStrategy 
> appender.rolling.strategy.max = 5   
> logger.rolling.name = 
> org.apache.logging.log4j.core.appender.RollingFileAppender 
> logger.rolling.level = debug 
> logger.rolling.additivity = false 
> logger.rolling.appenderRefs = rolling logger.rolling.appenderRef.rolling.ref 
> = RollingFile  {code}
> *+Update:+*
> When I add rootLogger level,
> {code:java}
> rootLogger.level = debug
> rootLogger.appenderRefs = rolling
> rootLogger.appenderRef.stdout.ref = RollingFile {code}
> am able to see the contents now in the file. Is it necessary to have root 
> logger configured always?
>  
> Although am still not able to generate multiple files based on each 
> application run. It just created application.log file and keeps on appending 
> the log of each run in the same file.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to