I want to log in my project, but it is logging on my desktop by default. How can I fix it?
Here are the log4j.properties
log4j.rootLogger=DEBUG, stdout, FILE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%-5p] (%F:%M:%L) %m%n
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=logs/joss.log
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d [%-5p] (%F:%M:%L) %m%n
Edit log4j.appender.FILE.File
where you want to save location.
I think your project is located at your desktop so log4j
is logging on your desktop because your log4j.properties
is written by logs/joss.log
AS-IS
log4j.appender.FILE.File=logs/joss.log
TO-BE
log4j.appender.FILE.File=C:/LOGGING_FILES_DIRECTORY/LOG_FILE_NAME.log
or just change from absolute path
to relative path
like below properties value. Then the log file(=joss.log) will be saved in your project directory([project root]/logs/joss.log).
log4j.appender.FILE.File=./logs/joss.log
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.