Did some Logger-Experiments so far - TODO: find out how to change rootlogger level
This commit is contained in:
parent
d1b2474702
commit
0e3e9aaa99
@ -34,8 +34,8 @@ dependencies {
|
||||
Since these are `implementation` dependencies, they are packed in the final jar.
|
||||
Read the documentation at https://docs.gradle.org/current/userguide/declaring_dependencies.html to learn more
|
||||
*/
|
||||
//implementation 'org.apache.logging.log4j:log4j-api:2.+'
|
||||
//implementation 'org.apache.logging.log4j:log4j-core:2.+'
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.+'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.+'
|
||||
|
||||
/*
|
||||
This is another example - it imports the javafx-controls dependency
|
||||
|
||||
14
src/main/java/ch/unibas/dmi/dbis/cs108/ log4j2.tld
Normal file
14
src/main/java/ch/unibas/dmi/dbis/cs108/ log4j2.tld
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="all">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
||||
|
||||
|
||||
import org.apache.logging.log4j.*;
|
||||
|
||||
public class Game {
|
||||
|
||||
/**
|
||||
@ -9,8 +12,6 @@ public class Game {
|
||||
protected int nrOfGhosts; // sets how many Ghosts we start witch
|
||||
protected int nrOfUsers; // safes how many clients are active in this Game
|
||||
protected GameFunctions gameFunctions;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Game instance where:
|
||||
*
|
||||
@ -24,15 +25,14 @@ public class Game {
|
||||
this.nrOfGhosts = nrOfGhosts;
|
||||
this.nrOfUsers = nrOfUsers;
|
||||
this.gameFunctions = new GameFunctions(nrOfPlayers, nrOfGhosts, nrOfUsers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
Game game1 = new Game(6, 1, 1);
|
||||
for (int j = 0; j < game1.nrOfPlayers; j++) {
|
||||
System.out.println(game1.gameFunctions.passengerTrain[j].getPosition());
|
||||
}
|
||||
|
||||
} catch (TrainOverflow e) {
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LoggingExp {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static void main(String[] args) {
|
||||
LOGGER.debug("I’m not printed by default ");
|
||||
LOGGER.error("An error , printed by default ");
|
||||
LOGGER.info("We can log variables with string concatenation :" + args);
|
||||
LOGGER.info("Or like this :{} ", args);
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package ch.unibas.dmi.dbis.cs108.example;
|
||||
|
||||
/**
|
||||
* A simple HelloWorld class.
|
||||
*/
|
||||
public class HelloWorld {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package ch.unibas.dmi.dbis.cs108.example.gui.javafx;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* This is an example JavaFX-Application.
|
||||
*/
|
||||
public class GUI extends Application {
|
||||
|
||||
/**
|
||||
* Launching this method will not work on some platforms.
|
||||
* What you should do is to create a separate main class and launch the GUI class from there as is done in {@link Main}
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String javafxVersion = System.getProperty("javafx.version");
|
||||
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
|
||||
Scene scene = new Scene(new StackPane(l), 640, 480);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package ch.unibas.dmi.dbis.cs108.example.gui.javafx;
|
||||
|
||||
import javafx.application.Application;
|
||||
|
||||
public class Main {
|
||||
|
||||
/**
|
||||
* This is simply a wrapper to launch the {@link GUI} class.
|
||||
* The reason this class exists is documented in {@link GUI#main(String[])}
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Application.launch(GUI.class, args);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package ch.unibas.dmi.dbis.cs108.example.gui.swing;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
/**
|
||||
* This is an example Swing Application
|
||||
*/
|
||||
public class SwingGUI {
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
// Make sure we have nice window decorations
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
// Create and set up the window.
|
||||
JFrame frame = new JFrame("HelloWorldSwing");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Add the ubiquitous "Hello World" label
|
||||
JLabel label = new JLabel("Hello World");
|
||||
frame.getContentPane().add(label);
|
||||
// Display the window
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Schedule a job for the event-dispatching thread: // creating and showing this application's GUI
|
||||
javax.swing.SwingUtilities.invokeLater(() -> createAndShowGUI());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user