日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

mybatis里的log适配器模式

發布時間:2024/4/18 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mybatis里的log适配器模式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

mybatis的日志級別可以在源碼中找到:trace,debug,warn,error,當mybatis想使用jdk的log實現類時,需要一個適配器進行轉化,因為log在jdk中實現的級別比mybatis多,適配器的類為Jdk14LoggingImpl

/** Copyright ${license.git.copyrightYears} the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/ package org.apache.ibatis.logging.jdk14;import java.util.logging.Level; import java.util.logging.Logger;import org.apache.ibatis.logging.Log;/*** @author Clinton Begin*/ //jdk log的適配器 public class Jdk14LoggingImpl implements Log {//真正提供日志能力的jdk日志類private final Logger log;public Jdk14LoggingImpl(String clazz) {log = Logger.getLogger(clazz);}@Overridepublic boolean isDebugEnabled() {return log.isLoggable(Level.FINE);}@Overridepublic boolean isTraceEnabled() {return log.isLoggable(Level.FINER);}@Overridepublic void error(String s, Throwable e) {log.log(Level.SEVERE, s, e);}@Overridepublic void error(String s) {log.log(Level.SEVERE, s);}@Overridepublic void debug(String s) {log.log(Level.FINE, s);}@Overridepublic void trace(String s) {log.log(Level.FINER, s);}@Overridepublic void warn(String s) {log.log(Level.WARNING, s);}}

可以看見完美的將jdk的log實現轉為mybatis的log實現

總結

以上是生活随笔為你收集整理的mybatis里的log适配器模式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。