You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OhmLogger.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package mvcgrafik.logger;
  7. import mvcgrafik.logger.MyFormatter;
  8. import java.io.File;
  9. import java.io.IOException;
  10. import java.util.logging.*;
  11. /**
  12. *
  13. * @author chris, hd
  14. */
  15. public class OhmLogger
  16. {
  17. public OhmLogger()
  18. {
  19. }
  20. private static Logger lg = null;
  21. public static Logger getLogger()
  22. {
  23. if (lg == null)
  24. {
  25. lg = Logger.getLogger("OhmLogger");
  26. initLogger();
  27. }
  28. return lg;
  29. }
  30. private static void initLogger()
  31. {
  32. try{
  33. String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
  34. FileHandler fh = new FileHandler(datei);
  35. ConsoleHandler ch = new ConsoleHandler();
  36. lg.addHandler(fh);
  37. ch.setFormatter(new MyFormatter());
  38. lg.setUseParentHandlers(false);
  39. lg.addHandler(ch);
  40. lg.setLevel(Level.ALL);
  41. }
  42. catch(IOException ioex)
  43. {
  44. System.err.println(ioex);
  45. }
  46. }
  47. }