File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 <maven .compiler.target>1.8</maven .compiler.target>
1212 <project .build.sourceEncoding>Cp1252</project .build.sourceEncoding>
1313 </properties >
14+
15+ <dependencies >
16+ <dependency >
17+ <groupId >org.apache.logging.log4j</groupId >
18+ <artifactId >log4j-api</artifactId >
19+ <version >[2.17.1,)</version >
20+ </dependency >
21+ <dependency >
22+ <groupId >org.apache.logging.log4j</groupId >
23+ <artifactId >log4j-core</artifactId >
24+ <version >[2.17.1,)</version >
25+ </dependency >
26+ </dependencies >
1427
1528 <build >
1629 <sourceDirectory >src/main/java</sourceDirectory >
Original file line number Diff line number Diff line change 1515import java .util .List ;
1616import java .util .StringTokenizer ;
1717
18+ import org .apache .logging .log4j .LogManager ;
19+ import org .apache .logging .log4j .Logger ;
20+
1821public class SQLExecutor implements AutoCloseable {
1922
23+ private static final Logger LOGGER = LogManager .getLogger (SQLExecutor .class );
24+
2025 private Connection con ;
2126 private boolean verbose ;
2227
@@ -39,6 +44,7 @@ public SQLExecutor(Connection con, boolean verbose) {
3944 public void exec (File file ) throws IOException , SQLException {
4045 Path path = Paths .get (file .getAbsolutePath ());
4146 String queries = new String (Files .readAllBytes (path ));
47+ LOGGER .info ("Queries " , queries );
4248 exec (queries );
4349 }
4450
@@ -78,7 +84,7 @@ public void exec(String sql) throws SQLException {
7884 for (SQLStatement stmt : statements ) {
7985
8086 if (verbose )
81- System . out . println ( stmt );
87+ LOGGER . info ( "SQL statement : " + stmt );
8288
8389 stmt .exec ();
8490 }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <Configuration status =" INFO" >
3+ <Appenders >
4+
5+ <Console name =" Console" target =" SYSTEM_OUT" >
6+ <PatternLayout pattern =" %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
7+ </Console >
8+
9+ <RollingFile name =" File" filename =" logs/latest.efsa.log"
10+ filePattern=" logs/$${date:yyyy-MM-dd-HH-mm-ss}.efsa.log" >
11+ <PatternLayout >
12+ <pattern >%d %p %c{1.} [%t] %m%n</pattern >
13+ </PatternLayout >
14+
15+ <Policies >
16+ <OnStartupTriggeringPolicy /> <!-- Every time that the application is run, a new log file is created -->
17+ </Policies >
18+
19+ <DefaultRolloverStrategy >
20+ <Delete basePath =" logs/" >
21+ <IfLastModified age =" 20d" />
22+ </Delete >
23+ </DefaultRolloverStrategy >
24+ </RollingFile >
25+
26+ </Appenders >
27+ <Loggers >
28+ <Root level =" info" >
29+ <AppenderRef ref =" Console" />
30+ <AppenderRef ref =" File" />
31+ </Root >
32+ </Loggers >
33+ </Configuration >
You can’t perform that action at this time.
0 commit comments