Giter VIP home page Giter VIP logo

slf4j-migrator's Introduction

SLF4J Migrator

This is a Python script which allows you to migrate Jakarta Commons Logging & Log4j in your Java source code to SLF4J Logging.

Python version compatibility

Code has been updated to be compatible with Python 3.x

What will be changed after running this migrator ?

1. "import" clause will be replaced with SLF4J

-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

2. log instance will be created with SLF4J

-private final static Logger log = Logger.getLogger(UserSessionFilter.class);
+private final static Logger log = LoggerFactory.getLogger(UserSessionFilter.class);

3. log clause will be standard SLF4J placeholder based instead of string conjunction

-log.info("UserName="+username+" had login attempted within " + delaySeconds + " seconds by same IP="+ipAddress+" address combination");
+log.info("UserName={} had login attempted within {} seconds by same IP={} address combination", username, delaySeconds, ipAddress);

4. Remove LogSF in Log4j

-LogSF.debug(log, "Input displayFileName={} originalFileName={}", uiTicTemp.getDisplayName(), uiTicTemp.getOriginalFileName());
+log.debug("Input displayFileName={} originalFileName={}", uiTicTemp.getDisplayName(), uiTicTemp.getOriginalFileName());

How to use this Migrator ?

1. Run the demo

python refine_logging.py

This will make the changes over all the sample java files in the current working folder. You could diff the changes by running

git diff

If you want to revert the java changes, running:

git reset --hard

2. Run the migrator in your java code base

cp refine_logging.py YOUR_JAVA_SRC_PATH
python refine_logging.py

The migrator will recursively scan and change your java files under YOUR_JAVA_SRC_PATH, take attention on the output of the script, it will prompt issues/infos if any.

slf4j-migrator's People

Contributors

ghosert avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

robertlee32

slf4j-migrator's Issues

SLF4j Migrating Issue

Dear Member,
I have SLF4J Migrator Version 1.7.5. My code is logged in by using LOG4J. After I migrated my whole code using the migrator, the code is getting converted partially. The formatting tags "{}" are not getting replaced. So that, I have to change the entire code manually. Hence, I would like to know,

  1. Is there any chance that I have missed while migrating?
  2. Why the entire code not replaced with SLF4J?

Thanks in advance.
Gopinath

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.