Where I have to put the file for using file appender log4j2 -
i new stackoverflow. trying set log4j2 in maven web application , want use file appender. found examples showing that..
<file name="myfile" filename="logs/app.log"> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> </file>
so. create folder "logs" , put app.log inside somewhere in application. log data not written file.
when change write in console testing purpose, can see log data in console.
i not sure have put "logs" folder.
my application directory that
src/main/java src/main/resources src/main/webapp src/test/java
thanks help.
can give full log4j2.xml file?
by default, file appender bufferedio=true, , immediateflush=true, output should flushed disk immediately. try adding explicit immediateflush attribute:
<file name="myfile" filename="logs/app.log" immediateflush="true">...
the logs folder relative app's current directory. may depend on web app server. find out logging result of system.getproperty("user.dir") console...
another thing try specify absolute path log file , see if file still not generated.
Comments
Post a Comment