zoukankan      html  css  js  c++  java
  • Hibernate4.3.5搭建Log4j日志环境

    本文记录Hibernate4.3.5搭建Log4j日志环境的过程

    1、搞清楚Hibernate4.3.5的日志环境依赖

    方法:查看帮助文档

    3.5. Logging
    
    Important
    Completely out of date. Hibernate uses JBoss Logging starting in 4.0. This will get documented as we migrate this content to the Developer Guide.
    Hibernate utilizes Simple Logging Facade for Java (SLF4J) in order to log various system events. SLF4J can direct your logging output to several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding. In order to setup logging you will need slf4j-api.jar in your classpath together with the jar file for your preferred binding - slf4j-log4j12.jar in the case of Log4J. See the SLF4J documentation for more detail. To use Log4j you will also need to place a log4j.properties file in your classpath. An example properties file is distributed with Hibernate in the src/ directory.

    第1段说hibernate4.0之后用JBoss Logging。具体怎么个用法还没研究过,第2段说Hibernate为了在不同的系统中记录日志利用了SLF4J,SLF4J是一套日志的接口,它可以匹配多种日志框架。为了 使用Log4j需要这两个jar包:slf4j-api.jar、slf4j-log4j12.jar。前者是slf4j的api包,后者是slf4j到log4j的适配器包。

    看到这问题就来了,这两个jar包去哪里找呢?

    方法:查看一下Hibernate4.3.5的lib目录里有没有,发现hibernate-release-4.3.5.Finalliboptionalehcache目录里有slf4j-api-1.6.1.jar,有了slf4j的api包,slf4j到log4j的适配器包去哪里找呢,去把slf4j官网把1.6.1下载下来看一下发现适配器官方发布包里面就有slf4j-1.6.1slf4j-log4j12-1.6.1.jar。

    有了这两个包就OK了吗?肯定不行啊,既然要搭建log4j日志环境,当然还需要log4j核心包,log4j的jar包版本那么多,我应该下载哪个版本呢?当然要下载适配器对应的版本了即:log4j-1.2.16,去官网下载下来。

    2、目录结构

    我们已经搞清楚了Hibernate4.3.5搭建log4j日志环境所需要的jar包,把他们添加到自己的工程里面,添加log4j的配置文件(示例文件:hibernate-release-4.3.5.Finalprojectetclog4j.properties),如此以后Hibernate4.3.5的log4j日志环境基本搞定。目录结构如下所示:

  • 相关阅读:
    PHP 实现下载文件到本地
    PHP 文件上传服务端及客户端配置参数说明
    报错: WARN hdfs.DFSClient: Caught exception java.lang.InterruptedException
    报错: Name node is in safe mode
    转载:CSS的组成,三种样式(内联式,嵌入式,外部式),优先级
    Windows 7 SP1 x64 旗舰版 微软官方安装U盘的制作
    jQuery滑过头像图片展示个人信息效果
    SQL Developer 4.1.3
    [转]内嵌页面iframe以及和其兄弟iframe的相互传值
    Environment variable:"PATH" 状态 失败
  • 原文地址:https://www.cnblogs.com/foreverngu/p/3870476.html
Copyright © 2011-2022 走看看