Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile

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.

like image 596
SyCode Avatar asked Mar 10 '18 09:03

SyCode


2 Answers

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/*
like image 190
Amin Heydari Alashti Avatar answered Nov 13 '22 00:11

Amin Heydari Alashti


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
like image 33
Vijay Gawade Avatar answered Nov 13 '22 01:11

Vijay Gawade