001/* 002 * jDTAUS Core RI Log4J Logging 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.logging.ri.log4j; 022 023import org.jdtaus.core.container.ContainerFactory; 024import org.jdtaus.core.logging.spi.Logger; 025 026/** 027 * jDTAUS Core SPI Log4J {@code Logger} implementation. 028 * <p>The name of the Log4J logger is specified by property {@code name}. 029 * Property {@code name} defaults to {@code org.jdtaus.runtime}.</p> 030 * 031 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 032 * @version $JDTAUS: Log4JLogger.java 8641 2012-09-27 06:45:17Z schulte $ 033 * 034 * @see org.jdtaus.core.container.Container 035 */ 036public class Log4JLogger implements Logger 037{ 038 //--Constructors------------------------------------------------------------ 039 040// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausConstructors 041 // This section is managed by jdtaus-container-mojo. 042 043 /** Standard implementation constructor <code>org.jdtaus.core.logging.ri.log4j.Log4JLogger</code>. */ 044 public Log4JLogger() 045 { 046 super(); 047 } 048 049// </editor-fold>//GEN-END:jdtausConstructors 050 051 //------------------------------------------------------------Constructors-- 052 //--Properties-------------------------------------------------------------- 053 054// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausProperties 055 // This section is managed by jdtaus-container-mojo. 056 057 /** 058 * Gets the value of property <code>name</code>. 059 * 060 * @return Name uniquely identifying the logger. 061 */ 062 public java.lang.String getName() 063 { 064 return (java.lang.String) ContainerFactory.getContainer(). 065 getProperty( this, "name" ); 066 067 } 068 069// </editor-fold>//GEN-END:jdtausProperties 070 071 //--------------------------------------------------------------Properties-- 072 //--Logger------------------------------------------------------------------ 073 074 public boolean isDebugEnabled() 075 { 076 return this.getLogger().isEnabledFor( org.apache.log4j.Level.DEBUG ); 077 } 078 079 public void debug( String string ) 080 { 081 this.getLogger().debug( string ); 082 } 083 084 public void debug( Throwable throwable ) 085 { 086 this.getLogger().debug( throwable.getMessage(), throwable ); 087 } 088 089 public boolean isErrorEnabled() 090 { 091 return this.getLogger().isEnabledFor( org.apache.log4j.Level.ERROR ); 092 } 093 094 public void error( String string ) 095 { 096 this.getLogger().error( string ); 097 } 098 099 public void error( Throwable throwable ) 100 { 101 this.getLogger().error( throwable.getMessage(), throwable ); 102 } 103 104 public boolean isFatalEnabled() 105 { 106 return this.getLogger().isEnabledFor( org.apache.log4j.Level.FATAL ); 107 } 108 109 public void fatal( String string ) 110 { 111 this.getLogger().fatal( string ); 112 } 113 114 public void fatal( Throwable throwable ) 115 { 116 this.getLogger().fatal( throwable.getMessage(), throwable ); 117 } 118 119 public boolean isInfoEnabled() 120 { 121 return this.getLogger().isEnabledFor( org.apache.log4j.Level.INFO ); 122 } 123 124 public void info( String string ) 125 { 126 this.getLogger().info( string ); 127 } 128 129 public void info( Throwable throwable ) 130 { 131 this.getLogger().info( throwable.getMessage(), throwable ); 132 } 133 134 public boolean isTraceEnabled() 135 { 136 return this.getLogger().isEnabledFor( org.apache.log4j.Level.TRACE ); 137 } 138 139 public void trace( String string ) 140 { 141 this.getLogger().trace( string ); 142 } 143 144 public void trace( Throwable throwable ) 145 { 146 this.getLogger().trace( throwable.getMessage(), throwable ); 147 } 148 149 public boolean isWarnEnabled() 150 { 151 return this.getLogger().isEnabledFor( org.apache.log4j.Level.WARN ); 152 } 153 154 public void warn( String string ) 155 { 156 this.getLogger().warn( string ); 157 } 158 159 public void warn( Throwable throwable ) 160 { 161 this.getLogger().warn( throwable.getMessage(), throwable ); 162 } 163 164 //------------------------------------------------------------------Logger-- 165 //--Log4JLogger------------------------------------------------------------- 166 167 /** 168 * Requests a Log4J logger for the name given by property {@code name}. 169 * 170 * @return the Log4J logger for the name given by property {@code name}. 171 */ 172 public org.apache.log4j.Logger getLogger() 173 { 174 return org.apache.log4j.Logger.getLogger( this.getName() ); 175 } 176 177 //-------------------------------------------------------------Log4JLogger-- 178}