diff --git a/.idea/java.iml b/.idea/java.iml index 40dfc33..e6e0748 100644 --- a/.idea/java.iml +++ b/.idea/java.iml @@ -7,10 +7,19 @@ - + - + + + + + + + + + + diff --git a/ProjectElectricLocomotive/FormLocomotiveCollections.java b/ProjectElectricLocomotive/FormLocomotiveCollections.java index de56d2f..a56bdf9 100644 --- a/ProjectElectricLocomotive/FormLocomotiveCollections.java +++ b/ProjectElectricLocomotive/FormLocomotiveCollections.java @@ -12,7 +12,6 @@ import org.apache.logging.log4j.*; public class FormLocomotiveCollections { private final Logger _logger; - FormElectricLocomotive formElectricLocomotive; FormLocomotiveConfig formLocomotiveConfig; private JPanel MainPanel; @@ -60,8 +59,8 @@ public class FormLocomotiveCollections { } _storage.AddSet(NameStorage); ReloadObjects(); - _logger.info("Добавлен набор: " + NameStorage); Refresh(); + _logger.info("Добавлен набор: " + NameStorage); }); ButtonRemoveObject.addActionListener(e -> @@ -72,6 +71,7 @@ public class FormLocomotiveCollections { JOptionPane.showMessageDialog(this.getPictureBoxCollections(), "Коллекция удалена", "Удаление", JOptionPane.INFORMATION_MESSAGE); _storage.DelSet((String) listBoxStorage.getSelectedValue()); //ТУТ СТРИНГ ОБРАТИ ВНИМАНИЕ КАК-НИБУДЬ ReloadObjects(); + _logger.info("Удален набор: " ); }); ButtonAddLocomotive.addActionListener(e -> { diff --git a/ProjectElectricLocomotive/Main.java b/ProjectElectricLocomotive/Main.java index 062171d..60ace1d 100644 --- a/ProjectElectricLocomotive/Main.java +++ b/ProjectElectricLocomotive/Main.java @@ -3,12 +3,18 @@ package ProjectElectricLocomotive; import org.apache.logging.log4j.*; public class Main { + private static Logger logger = LogManager.getLogger(Main.class); + public static void main(String[] args) { - System.setProperty("log4j.configutationFile", "C:\\code\\java\\ProjectElectricLocomotive\\loggerFile.xml"); + System.setProperty("log4j.configurationFile", "C:\\code\\java\\ProjectElectricLocomotive\\loggerFile.xml"); -// new FrameLocomotiveCollection(LogManager.getLogger("logger")); - FrameLocomotiveCollection frameLocomotiveCollection = new FrameLocomotiveCollection(LogManager.getLogger("logger")); + new FrameLocomotiveCollection(LogManager.getLogger("logger")); + //FrameLocomotiveCollection frameLocomotiveCollection = new FrameLocomotiveCollection(LogManager.getLogger("logger")); // new FormLocomotiveCollections(LogManager.getLogger(FormLocomotiveCollections.class)); + + + logger.info("hello"); + } } diff --git a/ProjectElectricLocomotive/log4j.properties b/ProjectElectricLocomotive/log4j.properties new file mode 100644 index 0000000..d59a8ee --- /dev/null +++ b/ProjectElectricLocomotive/log4j.properties @@ -0,0 +1,17 @@ + +# Root logger option +log4j.rootLogger=DEBUG, stdout, file + +# Redirect log messages to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Redirect log messages to a log file, support file rolling. +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=C:\logs.log +log4j.appender.file.MaxFileSize=5MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n