本文整理汇总了Java中org.apache.commons.logging.impl.Jdk14Logger类的典型用法代码示例。如果您正苦于以下问题:Java Jdk14Logger类的具体用法?Java Jdk14Logger怎么用?Java Jdk14Logger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Jdk14Logger类属于org.apache.commons.logging.impl包,在下文中一共展示了Jdk14Logger类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setJDKDebugEnabled
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
/**
* 开启DEBUG级别日志(仅针对JDK14LOGGER,LOG4J请自行修改配置文件)
*
* @param isEnabled
*/
public static void setJDKDebugEnabled(Boolean isEnabled) {
//如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
if (blog instanceof Jdk14Logger) {
Jdk14Logger logger = (Jdk14Logger) blog;
if (isEnabled) {
logger.getLogger().setLevel(Level.FINE);
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINE);
logger.getLogger().addHandler(consoleHandler);
} else {
logger.getLogger().setLevel(Level.INFO);
}
}
}
示例2: setJDKDebugEnabled
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
public static void setJDKDebugEnabled(Boolean isEnabled) {
//如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
if (blog instanceof Jdk14Logger) {
Jdk14Logger logger = (Jdk14Logger) blog;
if (isEnabled) {
logger.getLogger().setLevel(Level.FINE);
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINE);
logger.getLogger().addHandler(consoleHandler);
} else {
logger.getLogger().setLevel(Level.INFO);
}
}
}
示例3: doGet
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response
) throws ServletException, IOException {
// Do the authorization
if (!HttpServer.hasAdministratorAccess(getServletContext(), request,
response)) {
return;
}
PrintWriter out = ServletUtil.initHTML(response, "Log Level");
String logName = ServletUtil.getParameter(request, "log");
String level = ServletUtil.getParameter(request, "level");
if (logName != null) {
out.println("<br /><hr /><h3>Results</h3>");
out.println(MARKER
+ "Submitted Log Name: <b>" + logName + "</b><br />");
Log log = LogFactory.getLog(logName);
out.println(MARKER
+ "Log Class: <b>" + log.getClass().getName() +"</b><br />");
if (level != null) {
out.println(MARKER + "Submitted Level: <b>" + level + "</b><br />");
}
if (log instanceof Log4JLogger) {
process(((Log4JLogger)log).getLogger(), level, out);
}
else if (log instanceof Jdk14Logger) {
process(((Jdk14Logger)log).getLogger(), level, out);
}
else {
out.println("Sorry, " + log.getClass() + " not supported.<br />");
}
}
out.println(FORMS);
out.println(ServletUtil.HTML_TAIL);
}
示例4: enableDebug
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
/**
* Switches the logger for the given class to DEBUG level.
*
* @param clazz The class for which to switch to debug logging.
*/
public void enableDebug(Class<?> clazz) {
Log l = LogFactory.getLog(clazz);
if (l instanceof Log4JLogger) {
((Log4JLogger) l).getLogger().setLevel(org.apache.log4j.Level.DEBUG);
} else if (l instanceof Jdk14Logger) {
((Jdk14Logger) l).getLogger().setLevel(java.util.logging.Level.ALL);
}
}
示例5: enableDebug
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
/**
* Switches the logger for the given class to DEBUG level.
*
* @param clazz The class for which to switch to debug logging.
*/
public void enableDebug(Class<?> clazz) {
Logger l = LoggerFactory.getLogger(clazz);
if (l instanceof Log4JLogger) {
((Log4JLogger) l).getLogger().setLevel(org.apache.log4j.Level.DEBUG);
} else if (l instanceof Log4jLoggerAdapter) {
LogManager.getLogger(clazz).setLevel(org.apache.log4j.Level.DEBUG);
} else if (l instanceof Jdk14Logger) {
((Jdk14Logger) l).getLogger().setLevel(java.util.logging.Level.ALL);
}
}
示例6: doGet
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response
) throws ServletException, IOException {
// Do the authorization
if (!HttpServer.hasAdministratorAccess(getServletContext(), request,
response)) {
return;
}
PrintWriter out = ServletUtil.initHTML(response, "Log Level");
String logName = ServletUtil.getParameter(request, "log");
String level = ServletUtil.getParameter(request, "level");
if (logName != null) {
out.println("<br /><hr /><h3>Results</h3>");
out.println(MARKER
+ "Submitted Log Name: <b>" + logName + "</b><br />");
Logger log = LoggerFactory.getLogger(logName);
out.println(MARKER
+ "Log Class: <b>" + log.getClass().getName() +"</b><br />");
if (level != null) {
out.println(MARKER + "Submitted Level: <b>" + level + "</b><br />");
}
if (log instanceof Log4JLogger) {
process(((Log4JLogger)log).getLogger(), level, out);
} else if (log instanceof Jdk14Logger) {
process(((Jdk14Logger)log).getLogger(), level, out);
} else if (log instanceof Log4jLoggerAdapter) {
process(LogManager.getLogger(logName), level, out);
} else {
out.println("Sorry, " + log.getClass() + " not supported.<br />");
}
}
out.println(FORMS);
out.println(ServletUtil.HTML_TAIL);
}
示例7: init
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
moduleManager=new ModuleManager();
servletHome=config.getServletContext().getRealPath("/")+"WEB-INF";
moduleManager.setVariable("servletHome", servletHome);
// SimpleLog log=new SimpleLog("ModulesServlet");
// log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
Log log=new Jdk14Logger("ModulesServlet");
moduleManager.setLogging(log);
String configFile=config.getInitParameter("modulesconfig");
if(configFile==null) {
configFile=config.getInitParameter("modulesConfig");
if(configFile==null) configFile="modulesconfig.xml";
}
bindAddress=config.getInitParameter("bindaddress");
if(bindAddress==null){
bindAddress=config.getInitParameter("bindAddress");
}
moduleManager.addModule(servletModule,new ModuleSettings("rootServlet"));
moduleManager.readXMLOptionsFile(configFile);
if(bindAddress==null){
bindAddress=moduleManager.getVariable("bindAddress");
if(bindAddress==null) bindAddress=DEFAULT_BIND_ADDRESS;
}
try{
moduleManager.autostartModules();
}catch(ModuleException me){
throw new ServletException("Unable to start modules.",me);
}
}
示例8: WandoraModulesServer
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
public WandoraModulesServer(Wandora wandora){
this.wandora = wandora;
jettyServer = new Server();
rootLog = new Jdk14Logger("ModulesServlet");
log = rootLog;
Options options = wandora.getOptions();
readOptions(options);
mimeTypes = new MimeTypes();
initModuleManager();
readBundleDirectories();
}
示例9: run
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
@Test
public void run() throws OpenEJBException, NamingException, IOException {
final File tempWar = new File("target/AppDataSourceTest");
tempWar.mkdirs();
new File(tempWar, "WEB-INF").mkdirs();
IO.writeString(new File(tempWar, "WEB-INF/resources.xml"),
"<resources>\n" +
"<Resource id=\"java:app/gace/MyDS\" type=\"DataSource\">\n" +
"DataSourceCreator=dbcp\n" +
"</Resource>\n" +
"</resources>\n");
final Collection<LogRecord> records = new ArrayList<>();
try (final Container c = new Container(new Configuration().randomHttpPort())) {
Jdk14Logger.class.cast(LogFactory.getLog(BasicDataSource.class)).getLogger().addHandler(new Handler() {
@Override
public void publish(final LogRecord record) {
if (record.getLevel() == Level.SEVERE || record.getLevel() == Level.WARNING) {
records.add(record);
}
}
@Override
public void flush() {
// no-op
}
@Override
public void close() throws SecurityException {
// no-op
}
});
c.deploy(null, tempWar);
}
// if we have the JMX bug of dbcp2 integration (in 7.0.0) then we have a WARNING record from BasicDataSource.close()
// saying:
// Failed to unregister the JMX name:
// Tomcat:type=DataSource,host=localhost,context=/AppDataSourceTest,class=javax.sql.DataSource,name="openejb/Resource/AppDataSourceTest/app/gace/MyDS"
assertTrue(records.isEmpty());
}
示例10: init
import org.apache.commons.logging.impl.Jdk14Logger; //导入依赖的package包/类
@Before
public void init() throws SecurityException, IOException {
this.defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
this.logger = new Jdk14Logger(getClass().getName());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:JavaLoggingSystemTests.java