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:
https://logging.apache.org/log4j/2.x/manual/configuration.html
Under the section Property Substitution
On Wed, Feb 7, 2018 at 10:08 AM Jeremiah Schilens <[email protected]> wrote:
> 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] - <%m>%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] -
> <%m>}%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
>
> --
> - 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 [email protected].
> 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
> <https://groups.google.com/a/apereo.org/d/msgid/cas-user/e081da1e-45f1-4bd2-b59d-2a568d251f9d%40apereo.org?utm_medium=email&utm_source=footer>
> .
>
--
- 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/CAC_RtEbgi4E%3DXipCsUHy%2BFDH5kB--ECEJKdEQUn1FLvCXh9wSw%40mail.gmail.com.