Scriptella如何生成日志文件?

时间:2012-09-22 06:36:37

标签: logging etl scriptella

我希望Scriptella为每个原始文件生成一个日志文件,只需log4j为java应用程序进行ETL。如何做到这一点?

2 个答案:

答案 0 :(得分:1)

可以直接从ETL文件中调用任何日志记录API。可能最简单的方法是使用内置Rhino支持(JavaScript)的脚本驱动程序:

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <connection id="log4j" driver="script"/>

    <connection id="jul" driver="script"/>

    <script connection-id="jul">
        java.util.logging.Logger.getLogger("testLogger").info("This is JUL message");
    </script>

    <script connection-id="log4j">
        //For demo purposes!!!
        //Configures log4j to use console for output
        //Normally log4j should be configured by using a config file
        org.apache.log4j.BasicConfigurator.configure();
    </script>

    <script connection-id="log4j">
        org.apache.log4j.Logger.getLogger("testLoggerName").info("This is LOG4J message");
    </script>
</etl>

答案 1 :(得分:0)

您可以声明这样的连接

<connection id="log" driver="text" url="D:/tmp/out.log"/>

然后在您的查询中使用它

<query connection-id="dbConnectionIn">
    select * from table
    <script connection-id="log">
        Result  $column1, $comun2 
    </script>
</query>

现在将其记录到D:/ tmp

下的文件中