zoukankan      html  css  js  c++  java
  • java -cp

    java -cp /home/hdp/log4jTest/log4j-1.2.17.jar:/home/hdp/log4jTest/testLog.jar:/home/hdp/log4jTest/conf: test.TestLog

    要执行test.TestLog类。 test是包名。

    test.TestLog类在/home/hdp/log4jTest/testLog.jar中。

    依赖log4j-1.2.17.jar,所以在-cp中添加了这两个jar包。

    -cp中的最后一项 /home/hdp/log4jTest/conf: ,是将/home/hdp/log4jTest/conf目录下的配置文件加到类路径中。

    /home/hdp/log4jTest/conf中 我放置了log4j.properties。

     注意啊!!!一定要写成conf:  不能写成conf/*:

    所以一般程序将log4j的配置文件放置在jar包外面的。不需要打包到自己的jar包的。比如zookeeper就是这么做的。

  • 相关阅读:
    模块3 re + 正则表达式
    模块2
    模块1
    super
    MRO,C3算法
    日志,固定格式
    异常处理,MD5
    类的约束
    反射
    异常处理MR5
  • 原文地址:https://www.cnblogs.com/fanweiwei/p/3981413.html
Copyright © 2011-2022 走看看