diff --git a/dist/Programa Caja.jar b/dist/Programa Caja.jar index d439b59..0c26ae3 100644 Binary files a/dist/Programa Caja.jar and b/dist/Programa Caja.jar differ diff --git a/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java b/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java index 7c4fae7..70d5a9d 100644 --- a/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java +++ b/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java @@ -33,8 +33,11 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class SQLiteCajaDAO implements CajaDAO { + private static final Logger LOGGER = LogManager.getLogger(SQLiteCajaDAO.class); private SQLiteConnectionHolder connectionHolder; public SQLiteCajaDAO() { @@ -58,6 +61,7 @@ public class SQLiteCajaDAO implements CajaDAO { } } } catch (SQLException e) { + LOGGER.error("Error al intentar obtener todas las Cajas", e); } return cajaList; @@ -80,6 +84,7 @@ public class SQLiteCajaDAO implements CajaDAO { } } } catch (SQLException e) { + LOGGER.error("Error al intentar conseguir la caja con id " + id, e); } return Optional.ofNullable(caja); } @@ -101,6 +106,7 @@ public class SQLiteCajaDAO implements CajaDAO { } } } catch (SQLException e) { + LOGGER.error("Error al intentar conseguir la caja con fecha " + fecha, e); } return Optional.ofNullable(caja); } @@ -115,7 +121,6 @@ public class SQLiteCajaDAO implements CajaDAO { ps.executeUpdate(); } - query = "select last_insert_rowid()"; try (PreparedStatement ps = conn.prepareStatement("select last_insert_rowid()")) { try (ResultSet rs = ps.executeQuery()) { rs.next(); @@ -124,6 +129,7 @@ public class SQLiteCajaDAO implements CajaDAO { } } catch (SQLException e) { + LOGGER.error("Error al intentar insertar la caja " + caja, e); } } @@ -138,6 +144,7 @@ public class SQLiteCajaDAO implements CajaDAO { ps.executeUpdate(); } } catch (SQLException e) { + LOGGER.error("Error al intentar actualizar la caja " + caja, e); } } } diff --git a/src/resources/log4j2.properties b/src/resources/log4j2.properties index a32d236..975f3bf 100644 --- a/src/resources/log4j2.properties +++ b/src/resources/log4j2.properties @@ -6,13 +6,21 @@ filters = threshold filter.threshold.type = ThresholdFilter filter.threshold.level = debug -appenders = console +appenders = console, file appender.console.type = Console -appender.console.name = STDOUT +appender.console.name = console appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +appender.console.layout.pattern = %date{yyyy-MM-dd HH:mm:ss} [%level] [%logger{3}:%line] - %message %n + +appender.file.type = File +appender.file.name = file +appender.file.fileName = logs/debug.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %date{yyyy-MM-dd HH:mm:ss} [%level] [%logger{3}:%line] - %message %n rootLogger.level = debug -rootLogger.appenderRefs = stdout -rootLogger.appenderRef.stdout.ref = STDOUT +rootLogger.additivity = false +rootLogger.appenderRefs = console, file +rootLogger.appenderRef.stdout.ref = console +rootLogger.appenderRef.rolling.ref = file