diff --git a/pom.xml b/pom.xml index a3897d2e9..aca58f1e7 100644 --- a/pom.xml +++ b/pom.xml @@ -164,6 +164,16 @@ jaxb-api 2.3.0 + + ch.qos.logback + logback-classic + 1.3.11 + + + ch.qos.logback + logback-core + 1.3.11 + diff --git a/src/main/java/de/hbz/lobid/helper/CompareJsonMaps.java b/src/main/java/de/hbz/lobid/helper/CompareJsonMaps.java index c37620e2f..e4da6e52f 100644 --- a/src/main/java/de/hbz/lobid/helper/CompareJsonMaps.java +++ b/src/main/java/de/hbz/lobid/helper/CompareJsonMaps.java @@ -33,7 +33,7 @@ */ @SuppressWarnings("javadoc") public final class CompareJsonMaps { - final static Logger logger = LoggerFactory.getLogger(CompareJsonMaps.class); + final static Logger logger = LoggerFactory.getLogger("etl"); Stack stack = new Stack<>(); static final String JSON_LD_CONTEXT = "[@context"; private static boolean IGNORE_CONTEXT = true; diff --git a/src/main/java/de/hbz/lobid/helper/Etikett.java b/src/main/java/de/hbz/lobid/helper/Etikett.java index 23d282e61..5cd06f1f6 100644 --- a/src/main/java/de/hbz/lobid/helper/Etikett.java +++ b/src/main/java/de/hbz/lobid/helper/Etikett.java @@ -24,7 +24,7 @@ */ @XmlRootElement public class Etikett { - final static Logger logger = LoggerFactory.getLogger(Etikett.class); + final static Logger logger = LoggerFactory.getLogger("etl"); public enum EtikettType { CACHE, CONTEXT, STORE diff --git a/src/main/java/de/hbz/lobid/helper/EtikettMaker.java b/src/main/java/de/hbz/lobid/helper/EtikettMaker.java index 31b558a60..466f46eeb 100644 --- a/src/main/java/de/hbz/lobid/helper/EtikettMaker.java +++ b/src/main/java/de/hbz/lobid/helper/EtikettMaker.java @@ -29,7 +29,7 @@ public class EtikettMaker implements EtikettMakerInterface { private static final String ID = "id"; private String contextLocation = "web/conf/context.jsonld"; - final static Logger logger = LoggerFactory.getLogger(EtikettMaker.class); + final static Logger logger = LoggerFactory.getLogger("etl"); /** * A map with URIs as key diff --git a/src/main/java/de/hbz/lobid/helper/HttpPoster.java b/src/main/java/de/hbz/lobid/helper/HttpPoster.java index c318bf138..0e2742155 100644 --- a/src/main/java/de/hbz/lobid/helper/HttpPoster.java +++ b/src/main/java/de/hbz/lobid/helper/HttpPoster.java @@ -21,7 +21,7 @@ public final class HttpPoster { public final String POST = "POST"; private String contentType = "application/json"; private URL url; - private static final Logger LOG = LoggerFactory.getLogger(HttpPoster.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); /** * Creates an instance of {@link HttpPoster}. diff --git a/src/main/java/org/lobid/resources/ElasticsearchIndexer.java b/src/main/java/org/lobid/resources/ElasticsearchIndexer.java index 95b075580..4cf206ae9 100644 --- a/src/main/java/org/lobid/resources/ElasticsearchIndexer.java +++ b/src/main/java/org/lobid/resources/ElasticsearchIndexer.java @@ -64,7 +64,7 @@ public class ElasticsearchIndexer extends DefaultObjectPipe, ObjectReceiver> { - private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchIndexer.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); private String hostname; private String clustername; private BulkRequestBuilder bulkRequest; diff --git a/src/main/java/org/lobid/resources/EtikettJson.java b/src/main/java/org/lobid/resources/EtikettJson.java index 4d952c660..d6707ec4e 100644 --- a/src/main/java/org/lobid/resources/EtikettJson.java +++ b/src/main/java/org/lobid/resources/EtikettJson.java @@ -33,7 +33,7 @@ @Out(String.class) public final class EtikettJson extends DefaultObjectPipe> { - private static final Logger LOG = LoggerFactory.getLogger(EtikettJson.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); private String labelsDirectoryName = "labels"; private String contextFilenameLocation; private boolean generateContext = false; diff --git a/src/main/java/org/lobid/resources/JsonLdEtikett.java b/src/main/java/org/lobid/resources/JsonLdEtikett.java index ab30831d6..a56fb94a4 100644 --- a/src/main/java/org/lobid/resources/JsonLdEtikett.java +++ b/src/main/java/org/lobid/resources/JsonLdEtikett.java @@ -28,7 +28,7 @@ @Out(HashMap.class) public final class JsonLdEtikett extends DefaultObjectPipe, ObjectReceiver>> { - private static final Logger LOG = LoggerFactory.getLogger(JsonLdEtikett.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); private static String labelsDirectoryName = "labels"; private static String contextFilenameLocation = "web/conf/context.jsonld"; diff --git a/src/main/java/org/lobid/resources/run/AlmaMarcXmlFix2lobidJsonEs.java b/src/main/java/org/lobid/resources/run/AlmaMarcXmlFix2lobidJsonEs.java index a2af5d3b0..24d56c378 100644 --- a/src/main/java/org/lobid/resources/run/AlmaMarcXmlFix2lobidJsonEs.java +++ b/src/main/java/org/lobid/resources/run/AlmaMarcXmlFix2lobidJsonEs.java @@ -58,7 +58,7 @@ public class AlmaMarcXmlFix2lobidJsonEs { private static String triggerWebhookData; private static String kind = ""; private static boolean switchAutomatically = false; - private static final Logger LOG = LoggerFactory.getLogger(AlmaMarcXmlFix2lobidJsonEs.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); public static boolean threadAlreadyStarted = false; private static String switchAlias1; private static String switchAlias2; diff --git a/src/main/java/org/lobid/resources/run/SwitchEsAlmaAlias.java b/src/main/java/org/lobid/resources/run/SwitchEsAlmaAlias.java index 68d9d4e9c..52644e719 100644 --- a/src/main/java/org/lobid/resources/run/SwitchEsAlmaAlias.java +++ b/src/main/java/org/lobid/resources/run/SwitchEsAlmaAlias.java @@ -35,7 +35,7 @@ public final class SwitchEsAlmaAlias { private static final int DOCS_MINIMUM = 83000000; private static final int BYTES_MINIMUM = 49 * 1024 * 1024 * 1024; private static ObjectMapper objectMapper = new ObjectMapper(); - private static final Logger LOG = LoggerFactory.getLogger(SwitchEsAlmaAlias.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); private static StringBuilder logMessages = new StringBuilder(512); private SwitchEsAlmaAlias() { diff --git a/src/main/java/org/lobid/resources/run/UpdateAliases.java b/src/main/java/org/lobid/resources/run/UpdateAliases.java index 47e0e9507..02e3e03eb 100644 --- a/src/main/java/org/lobid/resources/run/UpdateAliases.java +++ b/src/main/java/org/lobid/resources/run/UpdateAliases.java @@ -41,7 +41,7 @@ */ public class UpdateAliases { private static ObjectMapper objectMapper = new ObjectMapper(); - private static final Logger LOG = LoggerFactory.getLogger(UpdateAliases.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); private static boolean success = false; private static String logMessage; private static StringBuilder logMessages = new StringBuilder(512); diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 412b596f7..c5968bd4e 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -7,8 +7,8 @@ - - + + diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 09de0a31e..32293b739 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -1,7 +1,7 @@ - + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 000000000..a466e7130 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,47 @@ + + + + etl.log + + + etl-log-%d{yyyy-MM-dd}.%i.gz + + 21 + + 100MB + + + %date{yyyy-MM-dd HH:mm:ss} [%level] %class{0} in %thread - %message%n%xException + + + + + + %coloredLevel %logger{15} - %message%n%xException{10} + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/lobid/resources/AlmaMarc21XmlToLobidJsonMetafixTest.java b/src/test/java/org/lobid/resources/AlmaMarc21XmlToLobidJsonMetafixTest.java index 7ffc32e40..fab4440c9 100644 --- a/src/test/java/org/lobid/resources/AlmaMarc21XmlToLobidJsonMetafixTest.java +++ b/src/test/java/org/lobid/resources/AlmaMarc21XmlToLobidJsonMetafixTest.java @@ -45,7 +45,7 @@ public final class AlmaMarc21XmlToLobidJsonMetafixTest { private static final File DIRECTORY = new File(DIRECTORY_NAME); final HashMap fixVariables = new HashMap<>(); private static final boolean GENERATE_TESTDATA = System.getProperty("generateTestData", "false").equals("true"); - private static final Logger LOG = LoggerFactory.getLogger(AlmaMarc21XmlToLobidJsonMetafixTest.class); + private static final Logger LOG = LoggerFactory.getLogger("etl"); // try patterns like e.g."662", NOT".*662" (which just would slow down) private static final String PATTERN_TO_IDENTIFY_XML_RECORDS = ""; diff --git a/web/app/controllers/resources/WebhookAlmaFix.java b/web/app/controllers/resources/WebhookAlmaFix.java index fe742b123..e3e00786b 100644 --- a/web/app/controllers/resources/WebhookAlmaFix.java +++ b/web/app/controllers/resources/WebhookAlmaFix.java @@ -2,10 +2,10 @@ package controllers.resources; +import ch.qos.logback.classic.LoggerContext; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.lobid.resources.run.AlmaMarcXmlFix2lobidJsonEs; -import play.Logger; import play.mvc.Controller; import play.mvc.Http; import play.mvc.Result; @@ -20,6 +20,9 @@ import java.util.List; import java.util.Objects; +import ch.qos.logback.classic.Logger; +import org.slf4j.LoggerFactory; + /** * Webhook listener starting update/basedump process for the Alma Fix ETL. Also use * to switch ES index alias. Reloads "webhook" configs dynamically, i.e. every @@ -55,6 +58,7 @@ public class WebhookAlmaFix extends Controller { + MSG_ETL_PROCESS_IS_ALREADY_RUNNING; private static final String MSG_CALLED_FROM_REMOTE_ADDRESS = "Called from: '%s' "; private static final String FIX_FILENAME = "conf/alma/alma.fix"; + private static final Logger etl = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger("etl"); // If null, create default values from Global settings public static String clusterHost = null; public static String clusterName = null; @@ -84,7 +88,7 @@ public static Result updateAlma(final String GIVEN_TOKEN) { try { msg = composeMessage(MSG_FILE_TOO_SMALL); if (Files.size(Paths.get(filenameUpdate.split(";")[0])) < 512) { - Logger.error(msg); + etl.error(msg); AlmaMarcXmlFix2lobidJsonEs.sendMail("Triggering of " + ETL_OF + KIND, false, msg); return status(500, msg); @@ -103,7 +107,7 @@ public static Result updateAlma(final String GIVEN_TOKEN) { return status(423, msg); } msg = composeMessage(String.format(msgStartEtl, KIND)); - Logger.info(msg); + etl.info(msg); AlmaMarcXmlFix2lobidJsonEs.setKindOfEtl(KIND); AlmaMarcXmlFix2lobidJsonEs.setSwitchAliasAfterETL(false); AlmaMarcXmlFix2lobidJsonEs.main(filenameUpdate, indexNameOfUpdate, @@ -117,7 +121,7 @@ public static Result updateAlma(final String GIVEN_TOKEN) { private static void reloadConfigs() { Config config = ConfigFactory.parseFile(new File(RESOURCES_CONF)).resolve(); - Logger.info("reload configs:" + RESOURCES_CONF); + etl.info("reload configs:" + RESOURCES_CONF); filenameUpdate = config.getString("webhook.alma.update.filename"); filenameBasedump = config.getString("webhook.alma.basedump.filename"); indexNameOfBasedump = config.getString("webhook.alma.basedump.indexname"); @@ -153,7 +157,7 @@ public static Result basedumpAlma(final String GIVEN_TOKEN) { try { if (Files.size(Paths.get(filenameBasedump)) < 512) { msg = composeMessage(MSG_FILE_TOO_SMALL); - Logger.error(msg); + etl.error(msg); AlmaMarcXmlFix2lobidJsonEs.sendMail("Triggering of " + ETL_OF + KIND, false, msg); return status(500, msg); @@ -170,7 +174,7 @@ public static Result basedumpAlma(final String GIVEN_TOKEN) { return status(423, msg); } msg = composeMessage(String.format(msgStartEtl, KIND)); - Logger.info(msg); + etl.info(msg); AlmaMarcXmlFix2lobidJsonEs.setKindOfEtl(KIND); if (basedumpSwitchAutomatically.equals("true")) { AlmaMarcXmlFix2lobidJsonEs.setSwitchAliasAfterETL(true); @@ -198,9 +202,9 @@ public static Result switchEsAlias(final String GIVEN_TOKEN) { reloadConfigs(); String subject = "switch aliases '" + alias1 + "' with '" + alias2 + "'"; String msg = composeMessage(subject); - Logger.info(msg); + etl.info(msg); if (!GIVEN_TOKEN.equals(token)) { - Logger.info("Wrong token: " + GIVEN_TOKEN); + etl.info("Wrong token: " + GIVEN_TOKEN); return wrongToken(subject, GIVEN_TOKEN); } boolean success; @@ -222,7 +226,7 @@ public static Result switchEsAlias(final String GIVEN_TOKEN) { private static Result wrongToken(final String KIND, final String GIVEN_TOKEN) { String msg = composeMessage(String.format(msgWrongToken, GIVEN_TOKEN, KIND)); - Logger.error(msg); + etl.error(msg); AlmaMarcXmlFix2lobidJsonEs.sendMail(KIND, false, msg); return forbidden(msg); } diff --git a/web/conf/logback.xml b/web/conf/logback.xml index 9a4127b71..c7f32c55b 100644 --- a/web/conf/logback.xml +++ b/web/conf/logback.xml @@ -1,10 +1,11 @@ - + ./logs/application.log application-log-%d{yyyy-MM-dd}.%i.gz + 21 @@ -13,6 +14,21 @@ %date{yyyy-MM-dd HH:mm:ss ZZZZ} [%level] from %logger in %thread - %message%n%xException + + + + ./logs/etl.log + + + etl-log-%d{yyyy-MM-dd}.%i.gz + + 21 + + 100MB + + + %date{yyyy-MM-dd HH:mm:ss} [%level] %class{0} in %thread - %message%n%xException + @@ -22,7 +38,7 @@ - + @@ -37,6 +53,9 @@ + + +