Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: How to close a LogWriter perminantly

  1. #1
    Join Date
    Sep 2005
    Posts
    1,403

    Default How to close a LogWriter perminantly

    Hi,


    I have wrote a java program that runs jobs.
    the main function there does the following:
    1. initializes a logWriter with a log file with the following format:
    "job_name_yyyy_mm_dd_hh_ss".



    2. initializes repository.



    3. executes the job.



    4.close the connction to the repository and the logWriter



    I copied from the kitchen.java code for doing so.
    The problem (of all places) is in step1.



    When running the first job a new lof file is created and all log messages are written to there - so far so good.
    But... when running the second (third, fourth etc) jobs a new log file is opened for them (this is good) but all messages are written both to the new log file and to all the previous log files as well (this is obviously NOT what I was expecting).



    Does anyone know what I am doing wrong?

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

    Default RE: How to close a LogWriter perminantly

    Again we get no indication on the version of Kettle you're using, but in 2.3.0:

    you create a file appender : LogWriter.createFileAppender()
    you close the file appender : appender.close()
    you remove the file appender: logWriter.removeAppender();

    HTH,
    Matt

  3. #3
    Join Date
    Sep 2005
    Posts
    1,403

    Default RE: How to close a LogWriter perminantly

    Hi Matt,

    Thanks for your reply.

    Sorry for not mentionning the verion (2.2.2) and the explicit code is something like this:

    ......
    String logLevel = "basic";

    LogWriter log = LogWriter.getInstance(fullFilePath, true,
    LogWriter.getLogLevel(logLevel)
    );

    //use LogWriter for a repository
    ......


    //closing log perminantly?
    log.close


    Is there a similar code like you wrote for version 2.2.2?

    Thanks again,
    Ora

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

    Default RE: How to close a LogWriter perminantly

    In 2.2.2 I guess you grab the output stream and close that.

    Use ((FileOutputStream)log.getStream()).close()

    That method is @deprecated though.

    Matt

  5. #5
    Join Date
    Sep 2005
    Posts
    1,403

    Default RE: How to close a LogWriter perminantly

    Thanks,

    I tried this, it certainly stops the multi logging but it causes errors coming from be.ibridge.kettle.core.logging.Log4jFileAppender.java such as:
    Unable to close Logging file ["my_file_name"] : Bad file descriptor, when going over its listed appenders.

    I can probably hack this error some how in somekind of ugly way, but I was intending to upgrade to 2.3 anyway.
    I will try upgrading today and try the firdt solution you proposed.

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

    Default RE: How to close a LogWriter perminantly

    Well, Kettle was being used more and more in ways that were not really intended originally.
    That's why we had to add the possibility to have multiple log files for example.
    And a way to close one, etc.

    We have no intention of back-porting this stuff to 2.2.2, so an upgrade would be the way to go.
    The release is only a couple of weeks away, so it's not that big a deal I guess.

    Matt

  7. #7
    Join Date
    Sep 2005
    Posts
    1,403

    Default RE: How to close a LogWriter perminantly

    Hi Matt,

    Just wanted to tell you I finished the upgrade to kettle 2.3.0.
    [Was easier than I expected though there isnt a full backword compatability, as before the kitchen.java helped me a lot in understanding the differences between versions when running jobs].

    I am using now the appenders you suggested and seems that everything is working great.


    Thanks again!
    Ora

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

    Default RE: How to close a LogWriter perminantly

    No, there is no 100% source compatibility. However, the transformations designed in 2.2.2 should run just the same on 2.3.0.

    If not, file a bug and we'll fix it :-)

    All the best,
    Matt

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.