Skip to content

Commit

Permalink
Add another logging destination (#1847)
Browse files Browse the repository at this point in the history
- introduces logging of ETL to a separate file
- separates external libs logs into dedicated log file
- change log pattern to be more concise
  • Loading branch information
dr0i committed Oct 20, 2023
1 parent 7809673 commit d2fd7d1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 73 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.3.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hbz/lobid/helper/Etikett.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ public Map<String, String> getMultilangLabel() {
return multilangLabel;
}

}
}
21 changes: 0 additions & 21 deletions src/main/resources/log4j.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<RollingFile name="RollingFile" fileName="logs/ETL.log" filePattern="ETL-log-%d{yyyy-ww}.gz" immediateFlush="true" append="true">
<RollingFile name="RollingFile" fileName="logs/etl-elasticsearch.log" filePattern="ETL_externallibs-log-%d{yyyy-ww}.gz" immediateFlush="true" append="true">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %level [%l] - %m%n"/>
<!-- Weekly rollover with compression -->
<Policies>
Expand Down
19 changes: 15 additions & 4 deletions web/app/controllers/resources/WebhookAlmaFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -87,19 +88,22 @@ public static Result updateAlma(final String GIVEN_TOKEN) {
Logger.error(msg);
AlmaMarcXmlFix2lobidJsonEs.sendMail("Triggering of " + ETL_OF + KIND, false,
msg);
Logger.warn(msg);
return status(500, msg);
}
}
catch (IOException e) {
msg = composeMessage(e.getMessage());
msg = composeMessage("Problems with data file\n" + e.getMessage());
AlmaMarcXmlFix2lobidJsonEs.sendMail("Triggering of " + ETL_OF + KIND, false,
msg);
return status(500, "Problems with data file\n" + msg);
Logger.warn(msg);
return status(500, msg);
}
if (AlmaMarcXmlFix2lobidJsonEs.threadAlreadyStarted) {
msg = composeMessage(String.format(MSG_UPDATE_ALREADY_RUNNING, indexNameOfUpdate));
AlmaMarcXmlFix2lobidJsonEs.sendMail(ETL_OF + KIND, false,
msg);
Logger.warn(msg);
return status(423, msg);
}
msg = composeMessage(String.format(msgStartEtl, KIND));
Expand Down Expand Up @@ -156,17 +160,21 @@ public static Result basedumpAlma(final String GIVEN_TOKEN) {
Logger.error(msg);
AlmaMarcXmlFix2lobidJsonEs.sendMail("Triggering of " + ETL_OF + KIND, false,
msg);
Logger.warn(msg);
return status(500, msg);
}
}
catch (IOException e) {
return status(500, "Problems with data file\n" + e);
msg = composeMessage("IO Problems with data file\n" + e);
Logger.warn(msg);
return status(500, msg);
}
createIndexNameOfBasedump = indexNameOfBasedump + "-" + LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyyMMdd-kkmm"));
if (AlmaMarcXmlFix2lobidJsonEs.threadAlreadyStarted) {
msg = composeMessage(String.format(MSG_CREATE_INDEX_ALREADY_RUNNING, createIndexNameOfBasedump));
AlmaMarcXmlFix2lobidJsonEs.sendMail(ETL_OF + KIND, false, msg);
Logger.warn(msg);
return status(423, msg);
}
msg = composeMessage(String.format(msgStartEtl, KIND));
Expand Down Expand Up @@ -200,22 +208,24 @@ public static Result switchEsAlias(final String GIVEN_TOKEN) {
String msg = composeMessage(subject);
Logger.info(msg);
if (!GIVEN_TOKEN.equals(token)) {
Logger.info("Wrong token: " + GIVEN_TOKEN);
return wrongToken(subject, GIVEN_TOKEN);
}
boolean success;
if (AlmaMarcXmlFix2lobidJsonEs.threadAlreadyStarted) {
msg = composeMessage(String.format(MSG_CREATE_INDEX_ALREADY_RUNNING, createIndexNameOfBasedump));
AlmaMarcXmlFix2lobidJsonEs.sendMail("Failed: " + subject, false, msg);
Logger.warn(msg);
return status(423, msg);
}
AlmaMarcXmlFix2lobidJsonEs.setSwitchVariables(alias1, alias2, clusterHost, basedumpSwitchMindocs, basedumpSwitchMinsize);
success = AlmaMarcXmlFix2lobidJsonEs.switchAlias();
if (success) {
msg = composeMessage(AlmaMarcXmlFix2lobidJsonEs.MSG_SUCCESS + subject);
Logger.info(msg);
return ok(msg);
}
msg = composeMessage(AlmaMarcXmlFix2lobidJsonEs.MSG_FAIL + subject);
Logger.warn("Wrong token: " + GIVEN_TOKEN);
return internalServerError(msg);
}

Expand All @@ -224,6 +234,7 @@ private static Result wrongToken(final String KIND,
String msg = composeMessage(String.format(msgWrongToken, GIVEN_TOKEN, KIND));
Logger.error(msg);
AlmaMarcXmlFix2lobidJsonEs.sendMail(KIND, false, msg);
Logger.warn(msg);
return forbidden(msg);
}

Expand Down
46 changes: 0 additions & 46 deletions web/conf/logback.xml

This file was deleted.

0 comments on commit d2fd7d1

Please sign in to comment.