ossiejhmoore icon

Untitled

ossiejhmoore | PRO | 05/18/18 02:04:15 PM UTC | 0 ⭐ | 362 👁️ | Never ⏰ | []
Java |

900 B

|

None

|

0 👍

/

0 👎

package deleteme;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
 
public class DeleteMe {
 
    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        logger.warn("Hello World");
    }
 
    //do once per class
    private static final Logger logger = Logger.getLogger(DeleteMe.class);
 
    static {
        //do this once, globally, not harmful to do it more often, just not needed
        try {
            File config = new File("logger.properties");
            InputStream is = new FileInputStream(config);
            PropertyConfigurator.configure(is);
        } catch (Exception e) {
            throw new RuntimeException(String.format("Crap.. log initialization failed! %", e.getLocalizedMessage()), e);
        }
    }
}

Comments