diff --git a/docker.sbt b/docker.sbt index a4d1ca309a..2e67f68a97 100644 --- a/docker.sbt +++ b/docker.sbt @@ -18,9 +18,10 @@ dockerExposedPorts := Seq(9000) daemonUser in Docker := "thehive" daemonGroup in Docker := "thehive" mappings in Docker ++= Seq( - file("package/docker/entrypoint") -> "/opt/thehive/entrypoint", - file("package/logback.xml") -> "/etc/thehive/logback.xml", - file("package/empty") -> "/var/log/thehive/application.log" + file("package/docker/entrypoint") -> "/opt/thehive/entrypoint", + file("package/logback.xml") -> "/etc/thehive/logback.xml", + file("package/logback-migration.xml") -> "/etc/thehive/logback-migration.xml", + file("package/empty") -> "/var/log/thehive/application.log" ) mappings in Docker ~= (_.filterNot { case (_, filepath) => filepath == "/opt/thehive/conf/application.conf" diff --git a/migration/src/main/scala/org/thp/thehive/migration/Migrate.scala b/migration/src/main/scala/org/thp/thehive/migration/Migrate.scala index 0160c2a21c..b55d474621 100644 --- a/migration/src/main/scala/org/thp/thehive/migration/Migrate.scala +++ b/migration/src/main/scala/org/thp/thehive/migration/Migrate.scala @@ -14,6 +14,9 @@ import scala.concurrent.duration.{Duration, DurationInt} import scala.concurrent.{Await, ExecutionContext} object Migrate extends App with MigrationOps { + Option(System.getProperty("logger.file")).getOrElse { + System.setProperty("logger.file", "/etc/thehive/logback-migration.xml") + } def getVersion: String = Option(getClass.getPackage.getImplementationVersion).getOrElse("SNAPSHOT") def addConfig(config: Config, settings: (String, Any)*): Config = ConfigFactory.parseMap(Map(settings: _*).asJava).withFallback(config) diff --git a/package.sbt b/package.sbt index c50cca85ad..bc6a06977a 100644 --- a/package.sbt +++ b/package.sbt @@ -3,12 +3,14 @@ import Common.remapPath // Install service files mappings in Universal ~= { _.flatMap { - case (_, "conf/application.conf") => Nil + case (_, "conf/application.conf") => Nil case (file, "conf/application.sample.conf") => Seq(file -> "conf/application.conf") - case (_, "conf/logback.xml") => Nil - case other => Seq(other) + case (_, "conf/logback.xml") => Nil + case (_, "conf/logback-migration.xml") => Nil + case other => Seq(other) } ++ Seq( - file("package/logback.xml") -> "conf/logback.xml" + file("package/logback.xml") -> "conf/logback.xml", + file("package/logback-migration.xml") -> "conf/logback-migration.xml" ) } @@ -38,8 +40,9 @@ linuxPackageMappings ++= Seq( file("package/thehive.service") -> "/usr/lib/systemd/system/thehive.service" ).withPerms("644"), packageMapping( - file("conf/application.sample.conf") -> "/etc/thehive/application.conf", - file("package/logback.xml") -> "/etc/thehive/logback.xml" + file("conf/application.sample.conf") -> "/etc/thehive/application.conf", + file("package/logback.xml") -> "/etc/thehive/logback.xml", + file("package/logback-migration.xml") -> "/etc/thehive/logback-migration.xml" ).withPerms("644").withConfig() ) daemonUser := "thehive" diff --git a/package/logback-migration.xml b/package/logback-migration.xml new file mode 100644 index 0000000000..1510ac6538 --- /dev/null +++ b/package/logback-migration.xml @@ -0,0 +1,44 @@ + + + + + + + /var/log/thehive/application.log + + /var/log/logs/application.%i.log.zip + 1 + 10 + + + 10MB + + + %date [%level] from %logger in %thread [%X{request}|%X{tx}] %message%n%xException + + + + + + %coloredLevel %message%n%xException{10} + + + + + + + + + + + + + + + + + + + + diff --git a/package/logback.xml b/package/logback.xml index bbd1c71212..dca626919e 100644 --- a/package/logback.xml +++ b/package/logback.xml @@ -2,12 +2,12 @@ + converterClass="play.api.libs.logback.ColoredLevel"/> /var/log/thehive/application.log - ${application.home:-.}/logs/application.%i.log.zip + /var/log/logs/application.%i.log.zip 1 10 @@ -15,30 +15,30 @@ 10MB - %date [%level] from %logger in %thread - %message%n%xException + %date [%level] from %logger in %thread [%X{request}|%X{tx}] %message%n%xException - %coloredLevel %logger{15} - %message%n%xException{10} + %coloredLevel %logger{15} [%X{request}|%X{tx}] %message%n%xException{10} - + - + - + - - + + - \ No newline at end of file +