File tree 5 files changed +99
-0
lines changed
CoreJavaProjects/tinylog-examples
java/com/journaldev/tinylog
5 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
2
+ xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
4
+ <modelVersion >4.0.0</modelVersion >
5
+ <groupId >com.journaldev</groupId >
6
+ <artifactId >tinylog-examples</artifactId >
7
+ <version >0.0.1-SNAPSHOT</version >
8
+
9
+ <dependencies >
10
+ <dependency >
11
+ <groupId >org.tinylog</groupId >
12
+ <artifactId >tinylog-api</artifactId >
13
+ <version >2.0.0-RC1</version >
14
+ </dependency >
15
+ <dependency >
16
+ <groupId >org.tinylog</groupId >
17
+ <artifactId >tinylog-impl</artifactId >
18
+ <version >2.0.0-RC1</version >
19
+ </dependency >
20
+ </dependencies >
21
+ </project >
Original file line number Diff line number Diff line change
1
+ package com .journaldev .tinylog ;
2
+
3
+ import org .tinylog .Logger ;
4
+
5
+ public class Employee {
6
+
7
+ private int id ;
8
+ private String name ;
9
+
10
+ public String getName () {
11
+ Logger .debug ("Returning employee name " + this .name );
12
+ return name ;
13
+ }
14
+
15
+ public void setName (String name ) {
16
+ Logger .info ("Setting employee name " + name );
17
+ this .name = name ;
18
+ }
19
+
20
+ public int getId () {
21
+ Logger .debug ("Returning employee id " + this .id );
22
+ return id ;
23
+ }
24
+
25
+ public void setId (int id ) {
26
+ Logger .info ("Setting employee id " + id );
27
+ this .id = id ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ package com .journaldev .tinylog ;
2
+
3
+ import org .tinylog .Logger ;
4
+
5
+ public class EmployeeMain {
6
+
7
+ public static void main (String [] args ) {
8
+
9
+ Logger .tag ("MAIN" ).debug ("Program Started" );
10
+
11
+ EmployeeService empService = new EmployeeService ();
12
+
13
+ Employee emp = empService .createEmployee (10 , "Pankaj" );
14
+
15
+ System .out .println ("Employee ID = " + emp .getId ());
16
+ System .out .println ("Employee Name = " + emp .getName ());
17
+
18
+ Logger .tag ("MAIN" ).debug ("Program Finished" );
19
+
20
+ }
21
+
22
+ }
Original file line number Diff line number Diff line change
1
+ package com .journaldev .tinylog ;
2
+
3
+ import org .tinylog .Logger ;
4
+
5
+ public class EmployeeService {
6
+
7
+ public Employee createEmployee (int i , String n ) {
8
+ Logger .info ("Creating Employee with ID = " + i + " and Name = " + n );
9
+ Employee emp = new Employee ();
10
+ emp .setId (i );
11
+ emp .setName (n );
12
+ return emp ;
13
+ }
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+ # writer = console
2
+ # writer.format = {date: HH:mm:ss.SSS} {tag} {level}: {message}
3
+
4
+ writer = rolling file
5
+ writer.file = tinylog{count}.txt
6
+ writer.level = info
7
+ writer.format = {date: HH:mm:ss.SSS} {tag} {level}: {message}
8
+ #
9
+ # writer1 = console
10
+ # writer1.level = debug
11
+ # writer.format = {date: HH:mm:ss.SSS} {tag} {level}: {message}
12
+ # writer1.tag = MAIN
You can’t perform that action at this time.
0 commit comments