Run liferay 7.0 logging using local time

thumbnail
William Gosse, modified 5 Years ago. Liferay Master Posts: 533 Join Date: 7/4/10 Recent Posts
Is there a way to setup liferay logging to use local time instead onUTC. I don't the want to change liferay's overall timezone. I want to keep it UTC. Only want to change logging so it syncs up better in ELK with all the other log information we collect.  Please note if it were up to me I'd just use UTC everywhere. This is coming from higher ups.
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Sure thing! But you have to work to get it there...


Basically you need to use a custom logger definition such as:
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
  <param name="file" value="log/volt.log">
  <param name="DatePattern" value="'.'yyyy-MM-dd">
  <layout class="[b][b]org.apache.log4j.EnhancedPatternLayout[/b][/b]">
     <param name="ConversionPattern" value="[b][b]%d{ISO8601}{GMT-5}[/b][/b]   %-5p [%t] %c: %m%n">
  </layout>
</appender>
You need to override the portal's logging using either a webapps/ROOT/WEB-INF/classes/META-INF/portal-log4j-ext.xml file (to change Liferay's core loggers), but with Liferay 7 there are additional ways to update module logging if you only need logs from a specific module to be formatted differently.
thumbnail
William Gosse, modified 5 Years ago. Liferay Master Posts: 533 Join Date: 7/4/10 Recent Posts
Thanks David!
thumbnail
William Gosse, modified 5 Years ago. Liferay Master Posts: 533 Join Date: 7/4/10 Recent Posts
Can I externalize the portal-log4j-ext.xml like the portal-ext.properties file?
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Unfortunately not.
thumbnail
William Gosse, modified 5 Years ago. Liferay Master Posts: 533 Join Date: 7/4/10 Recent Posts
Bummer but thanks again.