Migrated to Log4j2.

This commit is contained in:
Christian P. MOMON 2021-12-28 18:26:02 +01:00
parent b70b496bbf
commit 6b4e95c941
18 changed files with 20 additions and 15 deletions

View file

@ -12,9 +12,6 @@
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.3.jar" sourcepath="lib/commons-fileupload-1.3-sources.jar"/> <classpathentry kind="lib" path="lib/commons-fileupload-1.3.jar" sourcepath="lib/commons-fileupload-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.1.jar" sourcepath="lib/commons-lang3-3.1-sources.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.1.jar" sourcepath="lib/commons-lang3-3.1-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.5.jar" sourcepath="lib/Logs/slf4j-api-1.7.5-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.5.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.5-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/> <classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/> <classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.11.4.jar" sourcepath="lib/devinsy-strings-0.11.4-sources.zip"/> <classpathentry kind="lib" path="lib/devinsy-strings-0.11.4.jar" sourcepath="lib/devinsy-strings-0.11.4-sources.zip"/>
@ -26,5 +23,9 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/xidyn-1.11.2.jar" sourcepath="lib/xidyn-1.11.2-sources.zip"/> <classpathentry kind="lib" path="lib/xidyn-1.11.2.jar" sourcepath="lib/xidyn-1.11.2-sources.zip"/>
<classpathentry kind="lib" path="lib/commons-io-2.7.jar" sourcepath="lib/commons-io-2.7-sources.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.7.jar" sourcepath="lib/commons-io-2.7-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-api-2.17.0.jar" sourcepath="lib/Logs/log4j-api-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-core-2.17.0.jar" sourcepath="lib/Logs/log4j-core-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-slf4j-impl-2.17.0.jar" sourcepath="lib/Logs/log4j-slf4j-impl-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.32.jar" sourcepath="lib/Logs/slf4j-api-1.7.32-sources.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -25,6 +25,8 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -64,7 +66,7 @@ public class Kiss4webLauncher implements javax.servlet.ServletContextListener
if (StringUtils.isBlank(logFilePathname)) if (StringUtils.isBlank(logFilePathname))
{ {
org.apache.log4j.BasicConfigurator.configure(); Configurator.initialize(new DefaultConfiguration());
logger.warn("Log configuration undefined, use of the basic configurator."); logger.warn("Log configuration undefined, use of the basic configurator.");
} }
else else
@ -79,12 +81,12 @@ public class Kiss4webLauncher implements javax.servlet.ServletContextListener
if (new File(logFilePathname).exists()) if (new File(logFilePathname).exists())
{ {
org.apache.log4j.PropertyConfigurator.configure(logFilePathname); Configurator.initialize(null, logFilePathname);
} }
else else
{ {
System.out.println("Log configuration FILE NOT FOUND (" + logFilePathname + "), use of the basic configurator."); System.out.println("Log configuration FILE NOT FOUND (" + logFilePathname + "), use of the basic configurator.");
org.apache.log4j.BasicConfigurator.configure(); Configurator.initialize(new DefaultConfiguration());
} }
logger = LoggerFactory.getLogger(this.getClass()); logger = LoggerFactory.getLogger(this.getClass());

View file

@ -225,7 +225,7 @@ public class KissDispatcherUtils
if (servletClass == null) if (servletClass == null)
{ {
result = null; result = null;
logger.error("unknown page: [{}]", classPathname); logger.warn("unknown page: [{}]", classPathname);
} }
else else
{ {

View file

@ -17,6 +17,11 @@
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Kiss4web. If not, see <http://www.gnu.org/licenses/> * along with Kiss4web. If not, see <http://www.gnu.org/licenses/>
*/ */
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils; import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
/** /**
@ -24,18 +29,15 @@ import fr.devinsy.kiss4web.dispatcher.KissDispatcherUtils;
*/ */
public class FooSandbox public class FooSandbox
{ {
private static org.apache.log4j.Logger logger; private static org.apache.logging.log4j.Logger logger;
static static
{ {
// Initialize logger. // Initialize logger.
org.apache.log4j.Logger logger = null; org.apache.logging.log4j.Logger logger = null;
org.apache.log4j.BasicConfigurator.configure(); Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.INFO);
logger = org.apache.log4j.Logger.getRootLogger();
// logger.setLevel (org.apache.log4j.Level.INFO);
logger.setLevel(org.apache.log4j.Level.INFO);
logger.info("Enter"); logger.info("Enter");
@ -47,7 +49,7 @@ public class FooSandbox
logger.info("... done."); logger.info("... done.");
logger.debug("Exit"); logger.debug("Exit");
logger = org.apache.log4j.Logger.getLogger(FooSandbox.class.getName()); logger = LogManager.getLogger(FooSandbox.class.getName());
} }
/** /**