Skip to content

Commit

Permalink
logging to file
Browse files Browse the repository at this point in the history
* the logger output is now written into a file in the cemu_UI directory called app.log
  • Loading branch information
Seil0 committed Sep 2, 2017
1 parent 6c1663f commit 85fc66e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/application/
/resources/
/log4j2.xml
/snippet/
Binary file modified bin/application/Main.class
Binary file not shown.
19 changes: 15 additions & 4 deletions src/application/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ 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;
private File gamesDBFile;
@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) {
Expand Down Expand Up @@ -79,7 +79,7 @@ private void mainWindow(){
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");
Expand Down Expand Up @@ -188,6 +188,17 @@ private void firstStart(){
}

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);
}
}
19 changes: 13 additions & 6 deletions src/log4j2.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 85fc66e

Please sign in to comment.