I want my application to output logs to a the logfile in a user's home directory.
Therefore I have configured the log4j2.xml
file as below:
<Configuration>
<Properties>
<Property name="logfolder">/${sys:user.home}/xx/log/ff</Property>
</Properties>
<Appenders>
<RollingFile name="user_file" append="true" fileName="${logfolder}/logxyz.csv" filePattern="${logfolder}/old/$${date:yyyy-MM}/service-%d{MM-dd-yyyy}-%i.csv.gz">
<CsvParameterLayout format="Default" nullString="" charset="UTF-8"/>
<Policies>
I can see the logs in the specified folder, however, some errors are displayed in the console:
ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile : java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:\Users\xx/yy/log/abc/def.csv java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:\Users\xx/yy/log/abc/def.csv
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
The error seems to be related to parsing the windows files system, but I've got no idea how to go about this. Will appreciate any directions. I am developing on Windows 10, but the application logging should be cross-platform.
In my case, the user I ran the program had not the permission to create the log directory and write into it. So, I just changed the owner of the working directory and restarted the program without any problem.
sudo chown -R runner-user:runner-user working-directory/*
add full path to the directory according to operating system
if linux:
/opt/tomcat/apache-tomcat-9.0.27/webapps/My_Logs
if Windows: (Not Need generally append automatically )
C:\Program Files\Apache Software Foundation\Tomcat 9.0\My_Logs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With