Console/Log tab output to a log file

General
Raza Shah
2011-10-18
2013-05-28
  • Raza Shah

    Raza Shah - 2011-10-18

    Hi
    How do i get the log and console's output to file?
    I tried changing the log4j properties to output to a file appender and those logs are different what I see on the log and console tab.
    I need to keep track of all executions per se and in those cases when there are exceptions thrown, need go back and investigate.
    Also if theres an exception thrown on console/log tab, it wasnt wrriten on the log file i mentioned in logj4.properties
    So any pointer?
    Thanks.
    Regards

     
  • Rob Gordon

    Rob Gordon - 2011-10-19

    Hi - console output can be captured as you would for any other process and depends on your operating system. How are you running Oddjob and what have you tried? There should be no problem capturing log message to a file. Can you post the log4j configuation you are using?
    Thanks.

     
  • Rob Gordon

    Rob Gordon - 2011-10-21

    Hi - It looks like you're capturing the log from the client and what you want is the log from the server, so you need to change the log4j properties on the server to include your file appender.

    The console log from the exec job can be captured using it's stdout and stderr properties. Here's two examples one that redirects to a file, and one to the logger.

            <exec redirectStderr="true">
                <stdout>
                    <file file="${work.dir}/ExecOutput.log"/>
                </stdout>
                <![CDATA]>
            </exec>

            <exec>
                <stdout>
                    <logout level="INFO"/>
                </stdout>
                <stderr>
                    <logout level="WARN"/>
                </stderr>
                <![CDATA]>
            </exec>

    Hope this helps.
    Rob.

     
  • Raza Shah

    Raza Shah - 2011-10-21

    Rob
    Thanks for your prompt reply and sharing the example for stdout and stderr on exec.
    my jobs have those but somehow the exceptions are not caught there ( like whn job shows flower icon and there is some connection excption) its not there.
    I would make changes in server log4j, thanks a lot.
    hey aparently i cant modify/edit my post, is it possible for you to remove the logs from my prev post? l would really really appriciate tht.
    Regards

     
  • Rob Gordon

    Rob Gordon - 2011-10-21

    I couldn't modify the post so I deleted it.

    The exception will be logged to the stdout of the Oddjob process, not the stdout of the child process created with the Exec job. Where this is will depend on how Oddjob is started.

    Rob.

     
  • Raza Shah

    Raza Shah - 2011-10-25

    Rob
    Thanks for your timely help and responses.  and removing the logs too. thanks.
    Great i would try loging in different directories and see how it goes. I am sure once we have the elusive exception we can get to the root cause.
    Thanks once again :) appriciate it and great job on OddJob.
    Regards

     
  • henyo

    henyo - 2011-11-25


    this is my oddjob directory , and I have alter the log4j.properties like this:

    log4j.rootLogger=INFO,ROLLING_FILE

    log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender 
    log4j.appender.ROLLING_FILE.Threshold=ERROR 
    log4j.appender.ROLLING_FILE.File=rolling.log 
    log4j.appender.ROLLING_FILE.Append=true
    log4j.appender.ROLLING_FILE.MaxFileSize=10KB
    log4j.appender.ROLLING_FILE.MaxBackupIndex=1
    log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout 
    log4j.appender.ROLLING_FILE.layout.ConversionPattern=%5p  (%F:%L)  - %m%n

    when I use the xml as shown above :

    <oddjob>
    <job>
    <sequential>
    <jobs>
    <echo><![CDATA]></echo>
    <exec dir="." redirectStderr="true">
    <stdout>
    <logout level="INFO"/>
    </stdout>
    <stderr>
    <logout level="WARN"/>
    </stderr>
    <![CDATA[
    java -jar "E:\source\oddjob\maTest\c.jar"
    ]]>
    </exec>

    </jobs>
    </sequential>
    </job>
    </oddjob>
    ============================================================================================
    when I ran the job , where is the log file?   (rolling.log)  I cann`t find it anywhere.

     
  • Rob Gordon

    Rob Gordon - 2011-11-25

    With your configuration I get a rolling.log in the directory I started Oddjob:

    C:\rob\java\oddjob>java -jar run-oddjob.jar -f henyo.xml
    aaaaaaaaaaaaaaaaaa

    C:\rob\java\oddjob>dir rolling.log
    Volume in drive C has no label.
    Volume Serial Number is 5CDC-9E75

    Directory of C:\rob\java\oddjob

    25/11/2011  08:13                 0 rolling.log
                   1 File(s)              0 bytes
                   0 Dir(s)  134,195,625,984 bytes free

    The file is empty because the threshold is ERROR.

    If I change the threshold to INFO like this
    log4j.appender.ROLLING_FILE.Threshold=INFO

    I get:

    C:\rob\java\oddjob>java -jar run-oddjob.jar -f henyo.xml
    aaaaaaaaaaaaaaaaaa

    C:\rob\java\oddjob>dir rolling.log
    Volume in drive C has no label.
    Volume Serial Number is 5CDC-9E75

    Directory of C:\rob\java\oddjob

    25/11/2011  08:38             2,611 rolling.log
                   1 File(s)          2,611 bytes
                   0 Dir(s)  134,189,060,096 bytes free

    C:\rob\java\oddjob>type rolling.log
    INFO  (OddjobRunner.java:63)  - Starting Oddjob version 1.1.0_20111121
    INFO  (StructuralJob.java:120)  - Executing.
    INFO  (OddballsDirDescriptorFactory.java:49)  - Scannin
    g C:\rob\java\oddjob\oddballs for Oddballs.
    INFO  (DirectoryOddball.java:50)  - Addding Oddall [C:\
    rob\java\oddjob\oddballs\oj-ant]
    INFO  (DirectoryOddball.java:50)  - Addding Oddall [C:\
    rob\java\oddjob\oddballs\oj-hsql]
    INFO  (DirectoryOddball.java:50)  - Addding Oddall [C:\
    rob\java\oddjob\oddballs\oj-mail]
    INFO  (DirectoryOddball.java:50)  - Addding Oddall [C:\
    rob\java\oddjob\oddballs\oj-net]
    INFO  (Oddjob.java:601)  - Loading from configuration h
    enyo.xml
    INFO  (StructuralJob.java:120)  - Executing.
    INFO  (SequentialJob.java:78)  - Executing child
    INFO  (RunnableWrapper.java:215)  - Executing.
    INFO  (RunnableWrapper.java:230)  - Finished.
    INFO  (SequentialJob.java:78)  - Executing child

    INFO  (SimpleJob.java:87)  - Executing.
    INFO  (ExecJob.java:354)  - Command:  java -jar "E:\source\oddjo
    b\maTest\c.jar"
    INFO  (ExecJob.java:360)  - Args:   [E:\source\oddjo
    b\maTest\c.jar]
    INFO  (Log4jPrintStream.java:49)  - Unable to access jarfile
    E:\source\oddjob\maTest\c.jar
    INFO  (SimpleJob.java:98)  - Finished, result 1
    INFO  (SequentialJob.java:85)  - Child  failed. C
    an't continue.
    INFO  (StructuralJob.java:140)  - Execution finished.
    INFO  (StructuralJob.java:140)  - Execution finished.
    INFO  (OddjobRunner.java:114)  - Shutdown Hook Executing.
    INFO  (StructuralJob.java:170)  - Stopping.
    INFO  (StructuralJob.java:170)  - Stopping.
    INFO  (StructuralJob.java:200)  - Stopped.
    INFO  (StructuralJob.java:200)  - Stopped.
    INFO  (StructuralJob.java:170)  - Stopping.
    INFO  (StructuralJob.java:200)  - Stopped.
    INFO  (StructuralJob.java:170)  - Stopping.
    INFO  (StructuralJob.java:200)  - Stopped.
    INFO  (OddjobRunner.java:170)  - Oddjob terminating JVM with status
    1. Oddjob state .

    The error is coming out as INFO because you have redirectStderr as true on the exec job. Change that to false and you get that line as:

    WARN  (Log4jPrintStream.java:49)  - Unable to access jarfile
    E:\source\oddjob\maTest\c.jar

    Which I guess is what you want.

    Just to confirm
    - The log4j.properties I was changing is in opt/classes
    - There is no other log4j.properties on my classpath.

    One final tip - try setting the log4j.debug property:

    C:\rob\java\oddjob>java -Dlog4j.debug=true -jar run-oddjob.jar -f henyo.xml
    log4j: Trying to find  using context classloader Oddjob Launcher Clas
    sLoader.
    log4j: Trying to find  using Oddjob Launcher ClassLoader class loader
    .
    log4j: Trying to find  using ClassLoader.getSystemResource().
    log4j: Trying to find  using context classloader Oddjob Launch
    er ClassLoader.
    log4j: Using URL  for aut
    omatic log4j configuration.
    log4j: Reading configuration from URL file:/C:/rob/java/oddjob/opt/classes/log4j
    .properties
    log4j: Parsing for  with value=.
    log4j: Level token is .
    log4j: Category root set to INFO
    log4j: Parsing appender named "ROLLING_FILE".
    log4j: Parsing layout options for "ROLLING_FILE".
    log4j: Setting property  to [%5p  (%F:%L)  -
    %m%n].
    log4j: End of parsing for "ROLLING_FILE".
    log4j: Setting property  to .
    log4j: Setting property  to .
    log4j: Setting property  to .
    log4j: Setting property  to .
    log4j: Setting property  to .
    log4j: setFile called: rolling.log, true
    log4j: setFile ended
    log4j: Parsed "ROLLING_FILE" options.
    log4j: Finished configuring.
    aaaaaaaaaaaaaaaaaa

    Rob.

     
  • henyo

    henyo - 2011-11-25

    thank you very much, Rob!!!
    I run the commander as you write, I have got the same result. Then I checked my "oddjob/bin" folder,then I found the rolling.log ! It`s because I used the oddjob.bat  start oddjob with GUI,and the log file was in the directory  "oddjob/bin" .
    You have saved me from the  fog… thanks again!!!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks