Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Log4j - changes to log4j.xml not taking effect

  1. #1
    Join Date
    Oct 2011
    Posts
    13

    Default Log4j - changes to log4j.xml not taking effect

    Hi all,

    I'm using Kettle through a java application. I'm trying to hide the "INFO" log messages coming from Kettle engine but I'm not being able to.

    I tried to update the file log4j.xml from kettle-engine.jar by setting everything to "FATAL" just for a test, but it does not seem to take effect in my application - I still see all INFO and ERROR messages.

    Below is the code I updated. Does anyone have any idea? Is there something else I need to update to make it work? Thanks!

    Running: 4.2.0-stable

    <category name="org.pentaho">
    <priority value="FATAL"/>
    </category>

    <category name="com.healthmarketscience.jackcess">
    <priority value="FATAL"/>
    </category>

    <category name="org.apache.commons.httpclient">
    <priority value="FATAL"/>
    </category>

    <category name="org.mortbay">
    <priority value="FATAL"/>
    </category>

    <category name="java.net">
    <priority value="FATAL"/>
    </category>

    <category name="org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient">
    <priority value="FATAL"/>
    </category>

    <category name="org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient.auth">
    <priority value="FATAL"/>
    </category>

    <root>
    <priority value="FATAL"/>
    <appender-ref ref="CONSOLE"/>
    </root>
    Last edited by pabhb; 10-18-2011 at 10:32 AM.

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    The problem was detected a few weeks ago. The console logger for PDI is being put back programmatically even if you take it out of the log4j file. Believe it or not, someone requested that a few years back.
    The hack to get rid of it consists of running :

    Code:
    KettleEnvironment.init(); // normal
    Logger logger = Logger.getLogger(LogWriter.STRING_PENTAHO_DI_LOGGER_NAME);
    logger.removeLogger(LogWriter.STRING_PENTAHO_DI_CONSOLE_APPENDER);
    We'll get an environment variable to do that for you in the next release.

    HTH,

    Matt

  3. #3
    Join Date
    Oct 2011
    Posts
    13

    Default

    Thank you very much Matt, that worked - now all the PDI log is being hidden from the results.

    The only problem for me on this approach is that I will need to know the log when an error happened during Kettle processing. I'm trying to retrieve it from my java code but no success until now. I tried it by using getErrors from class Trans, but it didn't tell me a lot about my error. To illustrate, I need to be able to retrieve an error similar to this below (which was generated by a "Text file input" step):

    2011/10/18 12:58:49 - Text file input.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Unexpected error
    2011/10/18 12:58:49 - Text file input.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : org.pentaho.di.core.exception.KettleException:
    2011/10/18 12:58:49 - Text file input.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Error converting line
    2011/10/18 12:58:49 - Text file input.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) :
    2011/10/18 12:58:49 - Text file input.0 - ERROR (version 4.2.0-stable, build 15748 from 2011-09-08 13.11.42 by buildguy) : Couldn't parse field [Date] with value [xxxxxxxx]

    Any ideas? THANKS!

  4. #4
    Join Date
    Oct 2011
    Posts
    13

    Default

    Matt, please ignore my question below. I just figured out a way to do it by using your suggestion. I'm setting the log level in the code (which I will later grab from a properties file):

    Logger logger = Logger.getLogger(LogWriter.STRING_PENTAHO_DI_LOGGER_NAME);
    logger.setLevel(Level.ERROR);

    Thanks a lot again!

  5. #5
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Actually, you can ask the central log store for the log lines, where they came from, which step, time and so on...

    See: http://wiki.pentaho.com/display/EAI/PDI+Logging

  6. #6
    Join Date
    Oct 2011
    Posts
    13

    Default

    Thank you very much Matt. This line below was everything I needed to do what I was trying to.

    Logger logger = Logger.getLogger(LogWriter.STRING_PENTAHO_DI_LOGGER_NAME);

    Thanks again!

  7. #7
    Join Date
    May 2012
    Posts
    4

    Default

    http://forums.pentaho.com/showthread...-taking-effect


    Hi I have same problem. I have to disable the debug logging from log4j.xml. i have to change debug to warn in order to move the code into production
    I changed as
    <category name="org.pentaho">
    <!--<priority value="DEBUG"/>-->
    <priority value="WARN"/>
    </category>
    in the log4j.xml file which exist in the kettle-engine.jar file
    but still when i run the ETL process it is logging with debug information like below. how do i log starting from WARN...

    DEBUG [di,[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)',4082] - 27-Aug 12:28:42 org.pentaho.di.core.util.ResolverUtil@e81c10 - Checking to see if class org.pentaho.di.job.entries.mailvalidator.Messages matches criteria [annotated with @Job]
    Here is my log4j.xml
    <category name="org.pentaho">
    <!--<priority value="DEBUG"/>-->
    <priority value="WARN"/>
    </category>

    <category name="com.healthmarketscience.jackcess">
    <priority value="WARN"/>
    </category>

    <category name="org.apache.commons.httpclient">
    <priority value="WARN"/>
    </category>

    <category name="org.mortbay">
    <priority value="ERR"/>
    </category>

    <category name="java.net">
    <priority value="NONE"/>
    </category>

    <category name="org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient">
    <priority value="WARN"/>
    </category>

    <category name="org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient.auth">
    <priority value="WARN"/>
    </category>

    <root>
    <priority value="INFO"/>
    <appender-ref ref="CONSOLE"/>
    </root>

    </log4j:configuration>

  8. #8
    Join Date
    Sep 2012
    Posts
    19

    Default

    Hi,

    This problem is always available. The log is programmatically defined as Matt explians below so changing the log4j.xml has no effect.
    My solution (certainly not the best) is to redefine the log each time before firing a job or transformation like this (running stable 4.3):
    Code:
    Logger logger = Logger.getLogger(LogWriter.STRING_PENTAHO_DI_LOGGER_NAME);
    Logger logger2 = Logger.getLogger("org.pentaho");
    @SuppressWarnings("unchecked")
    Enumeration<Appender> e = logger2.getAllAppenders();
    while (e.hasMoreElements()) {
      Appender appender = (Appender) e.nextElement();
      logger.addAppender(appender);
    }
    logger.setLevel(logger2.getLevel())
    ;



    By this way you apply the configuration of log4j on pentaho

    The logger in log4j is defined as this
    Code:
        <logger name="org.pentaho" additivity="true">
               <level value="debug"/>
            <appender-ref ref="CA"/>
            <appender-ref ref="FABig"/>
            <appender-ref ref="FA"/>
        </logger>

    I publish this answer because I have searched for more than one hour before finding that post with the way to the solution.

    Regards,

    Jer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.