logging to file

* the logger output is now written into a file in the cemu_UI directory called app.log
This commit is contained in:
Jannik 2017-09-02 17:38:40 +02:00
parent 6c1663f386
commit 85fc66e8d6
4 changed files with 29 additions and 10 deletions

1
bin/.gitignore vendored
View File

@ -1,3 +1,4 @@
/application/
/resources/
/log4j2.xml
/snippet/

Binary file not shown.

View File

@ -41,8 +41,8 @@ public class Main extends Application {
CloudController cloudController;
AnchorPane pane;
private Scene scene;
private String dirWin = System.getProperty("user.home") + "/Documents/cemu_UI"; //Windows: C:/Users/"User"/Documents/HomeFlix
private String dirLinux = System.getProperty("user.home") + "/cemu_UI"; //Linux: /home/"User"/HomeFlix
private String dirWin = System.getProperty("user.home") + "/Documents/cemu_UI"; //Windows: C:/Users/"User"/Documents/cemu_UI
private String dirLinux = System.getProperty("user.home") + "/cemu_UI"; //Linux: /home/"User"/cemu_UI
private String gamesDBdownloadURL = "https://github.com/Seil0/cemu_UI/raw/master/downloadContent/games.db";
private File directory;
private File configFile;
@ -50,7 +50,7 @@ public class Main extends Application {
@SuppressWarnings("unused")
private File localDB;
private File pictureCache;
private static final Logger LOGGER = LogManager.getLogger(Main.class.getName());
private static Logger LOGGER;
@Override
public void start(Stage primaryStage) {
@ -79,7 +79,7 @@ public class Main extends Application {
pictureCache= new File(dirLinux+"/picture_cache");
pane.setPrefWidth(904); //this could be a kde plasma specific issue
}else{
directory = new File(dirWin);
directory = new File(dirWin);
configFile = new File(dirWin + "/config.xml");
gamesDBFile = new File(dirWin + "/games.db");
localDB = new File(dirWin+"/localRoms.db");
@ -188,6 +188,17 @@ public class Main extends Application {
}
public static void main(String[] args) {
//delete old log file and create new
if(System.getProperty("os.name").equals("Linux")){
System.setProperty("logFilename", System.getProperty("user.home") + "/cemu_UI/app.log");
File logFile = new File(System.getProperty("user.home") + "/cemu_UI/app.log");
logFile.delete();
}else{
System.setProperty("logFilename", System.getProperty("user.home") + "/Documents/cemu_UI/app.log");
File logFile = new File(System.getProperty("user.home") + "/Documents/cemu_UI/app.log");
logFile.delete();
}
LOGGER = LogManager.getLogger(Main.class.getName());
launch(args);
}
}

View File

@ -1,13 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %c{1} - %msg%n" />
</Console>
<File name="file" fileName="${sys:logFilename}" immediateFlush="true">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %c{1} - %msg%n" />
</File>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
<Root level="debug" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="file"/>
</Root>
</Loggers>
</Configuration>
</Configuration>