How to change Log4j PatternLayout in the Project Settings to display a DateTime value on logs?

Question

How to change the Log4j pattern layout in the Project Settings to display a DateTime value in logs?

 

Answer

The project settings use Log4j. To change them, open the project in Studio and select File > Edit Project Properties.

Then in the Project Settings window, select Log4j. This is where the PatternLayout value can be edited as desired.

2017-10-13 08_34_34-Talend Data Fabric (6.4.1.20170623_1246) _ admin, admin _ git (Connection_ Remot.png

To get output as shown below:

[INFO ] - 13 Oct 2017 08:19:47:443 - TalendJob: 'Parent' - Start.

Change log4j project setting to:

<!-- CONSOLE appender -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
   <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
         value="[%-5p] - %d{dd MMM yyyy HH:mm:ss:SSS} - %m%n" />
   </layout>
</appender>

See the following documentation for the available Patterns: Apache Log4j Class PatternLayout

Version history
Revision #:
3 of 3
Last update:
‎09-29-2018 12:12 AM
Updated by:
 
Labels (3)