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

17,198

Solution 1

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/*

Solution 2

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
Share:
17,198
SyCode
Author by

SyCode

I have a passion for information security and methods for building secure, modern applications that leverage contemporary technologies e.g. cloud (IaaS) and containers (e.g Docker, Kubernetes). Therefore, I am interested in aspects relating to SecDevOps, CloudDevOps, security risk analysisetc.

Updated on June 08, 2022

Comments

  • SyCode
    SyCode almost 2 years

    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.