ossiejhmoore

Untitled

May 18th, 2018
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. package deleteme;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.InputStream;
  6. import org.apache.log4j.Logger;
  7. import org.apache.log4j.PropertyConfigurator;
  8.  
  9. public class DeleteMe {
  10.  
  11.     @SuppressWarnings("unchecked")
  12.     public static void main(String[] args) throws Exception {
  13.         logger.warn("Hello World");
  14.     }
  15.  
  16.     //do once per class
  17.     private static final Logger logger = Logger.getLogger(DeleteMe.class);
  18.  
  19.     static {
  20.         //do this once, globally, not harmful to do it more often, just not needed
  21.         try {
  22.             File config = new File("logger.properties");
  23.             InputStream is = new FileInputStream(config);
  24.             PropertyConfigurator.configure(is);
  25.         } catch (Exception e) {
  26.             throw new RuntimeException(String.format("Crap.. log initialization failed! %", e.getLocalizedMessage()), e);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment