cas-management 5.x cas-management.log java.io.IOException: Permission denied

772 views
Skip to first unread message

Jeremiah Schilens

unread,
Feb 7, 2018, 1:08:00 PM2/7/18
to CAS Community
Hello,

I'm working on the cas-management-overlay for 5.x and it doesn't seem to be honoring the settings in the log4j2-management.xml. In my management.properties I have:

cas.log.dir=/u01/app/tomcat/logs/
logging.config=file:///etc/cas/config/log4j2-management.xml

and in the log4j2-management.xml file I have
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Specify the refresh internal in seconds. -->
<Configuration monitorInterval="60" packages="org.apereo.cas.logging">
    <Properties>
        <!--
        Default log directory is the current directory but that can be overridden with -Dcas.log.dir=<logdir>
        Or you can change this property to a new default
        -->
        <Property name="cas.log.dir" >/not/the/patht/logs/</Property>
        <!-- To see more CAS specific logging, adjust this property to info or debug or run server with -Dcas.log.leve=debug -->
        <Property name="cas.log.level" >info</Property>
    </Properties>
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %p [%c] - &lt;%m&gt;%n"/>
        </Console>
        <RollingFile name="cas-management" fileName="${sys:cas.log.dir}/cas-management.log" append="true"
                     filePattern="${sys:cas.log.dir}/cas-management-%d{yyyy-MM-dd-HH}-%i.log.gz">
            <PatternLayout pattern="%d %p [%c] - %m%n"/>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="512 KB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
    </Appenders>

But when the management app starts up it prints 
localhost-startStop-1 ERROR Unable to create file cas-management.log java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:1012)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:628)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)
        at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
        at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115)
        at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
...

Once the war deploys, if I look in  cas-management/WEB-INF/classes/log4j2.xml it has 
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Specify the refresh internal in seconds. -->
<Configuration monitorInterval="15">
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%highlight{%d %p [%c] - &lt;%m&gt;}%n"/>
        </Console>
        <RollingFile name="cas-management" fileName="cas-management.log" append="true"
                     filePattern="cas-management-%d{yyyy-MM-dd-HH}-%i.log.gz">
            <PatternLayout pattern="%d %p [%c] - %m%n"/>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="512 KB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
    </Appenders>


If I look in the CAS app log4j.xml after deploy the file line is
 <RollingFile name="file" fileName="${baseDir}/cas.log" append="true"


Am I right in thinking this is a bug and the source for cas-management log4j.xml should be updated to have ${baseDir} added? Or am I missing something in my config?

Thank you,

Jeremiah

Travis Schmidt

unread,
Feb 7, 2018, 3:04:19 PM2/7/18
to cas-...@apereo.org
Setting cas.log.dir in management.properties does not override System properties.  At least not that I was able to figure out.  So passing -Dcas.log.dir=/some/dir/ to your startup script should sub ${sys:cas.log.dir} correctly in your log42j.xml.  I also think that setting a default in the .xml file to be overridden by sys property is not achievable.  If you just want to set the log dir in property file in the xml, then just use ${cas.log.dir} and drop the sys: prefix.  

More on this can be found here:


Under the section Property Substitution


--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/e081da1e-45f1-4bd2-b59d-2a568d251f9d%40apereo.org.

SCHILENS, JEREMIAH

unread,
Feb 8, 2018, 12:08:42 PM2/8/18
to cas-...@apereo.org

Hi Travis,

 

Thank you for that information. I thought I was overriding the log4j.xml files by putting them in etc/cas/config for each overlay but I just noticed I’m not. The reason the cas log4j works for me without permission error is because it sets baseDir to /etc/cas/logs. (https://github.com/apereo/cas/blob/master/webapp/resources/log4j2.xml)

The cas-management doesn’t set base-dir https://github.com/apereo/cas-management/blob/master/webapp-mgmt/cas-management-webapp/src/main/resources/log4j2.xml

 

Sorry I think this is a basic question, but with the overlay how do I override specific files in the targets maven builds? I tried creating the path and file in my build.sh directory but that didn’t work.

 

Thank you,

 

Jeremiah

Message has been deleted

Janina Byky

unread,
Feb 15, 2018, 9:23:57 AM2/15/18
to CAS Community
Hi,

I was facing the same problem, all write/execute/read rights and ownerships were correct and tomcat could access all mentioned directories but still there was an error on startup.

Only one thing worked for me. In cas-management-overlay I've overridded log4j2.xml (src/main/resources/log4j2.xml) with my options and after rebuild everything seems to be working fine.

SCHILENS, JEREMIAH

unread,
Feb 16, 2018, 10:19:52 AM2/16/18
to cas-...@apereo.org

Hello,

 

I did find a solution. My previous experience with 3.5.2 taught me about over-riding the source files using the overlay, I just hadn’t seen how to do it with this version until I found: https://apereo.github.io/2017/03/28/cas5-gettingstarted-overlay/

 

For me it was:

cd cas-management-overlay

mkdir -p src/main/webapp/WEB-INF/classes

cp etc/cas/config/log4j2-management.xml  src/main/webapp/WEB-INF/classes /log4j2.xml

 

My log4j2-management.xml already had the changes I wanted.

 

Hope this helps,

 

Jeremiah

 

From: cas-...@apereo.org [mailto:cas-...@apereo.org] On Behalf Of Janina Byky
Sent: Wednesday, February 14, 2018 7:09 AM
To: CAS Community <cas-...@apereo.org>
Subject: Re: [cas-user] cas-management 5.x cas-management.log java.io.IOException: Permission denied

 

Hi Jeremiah,

 

I'm also struggling with this issue. Did you developed any working solution ? 

Reply all
Reply to author
Forward
0 new messages