Skip to content

Commit

Permalink
Merge pull request #1 from opensrp/replace-logger
Browse files Browse the repository at this point in the history
Migrate to logger to log4j2
  • Loading branch information
ellykits authored May 26, 2021
2 parents 600e5f7 + 7e193b4 commit d499ca3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ For example run the following command to list available options (`app.properties

```shell script

java -jar opensrp-data-import-2.0.2-SNAPSHOT-fat.jar --configs-file app.properties --help
java -jar opensrp-data-import-2.0.3-SNAPSHOT-fat.jar --configs-file app.properties --help

```

Expand Down Expand Up @@ -107,7 +107,7 @@ java -jar opensrp-data-import-2.0.2-SNAPSHOT-fat.jar --configs-file app.properti

```shell script

java -jar opensrp-data-import-2.0.2-SNAPSHOT-fat.jar --configs-file app.properties --users-file users.csv --source-file locations.csv --assign-team "Health Facility" --import locations
java -jar opensrp-data-import-2.0.3-SNAPSHOT-fat.jar --configs-file app.properties --users-file users.csv --source-file locations.csv --assign-team "Health Facility" --import locations

```

Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "org.smartregister"
version = "2.0.2-SNAPSHOT"
version = "2.0.3-SNAPSHOT"

repositories {
mavenCentral()
Expand All @@ -30,7 +30,7 @@ application {
val vertxVersion = "4.0.2"
val junitJupiterVersion = "5.7.0"
val kotlinSerializationVersion = "1.2.0"
val logbackVersion = "1.2.3"
val log4jVersion = "2.14.1"
val cliktVersion = "3.1.0"
val openCsvVersion = "5.4"

Expand All @@ -46,7 +46,7 @@ dependencies {
implementation("io.vertx:vertx-config")
implementation("io.vertx:vertx-circuit-breaker")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
implementation("com.github.ajalt.clikt:clikt:$cliktVersion")
implementation("com.opencsv:opencsv:$openCsvVersion")

Expand Down Expand Up @@ -89,7 +89,7 @@ tasks.withType<JavaExec> {
"--redeploy=$watchForChange",
"--launcher-class=$launcherClassName",
"--on-redeploy=$doOnChange",
"-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory",
"-Dvertx.logger-delegate-factory-class-name=Log4j2LogDelegateFactory",
"-Denvironment=dev"
)
}
2 changes: 1 addition & 1 deletion src/main/kotlin/org/smartregister/dataimport/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.smartregister.dataimport.shared.*

fun main() {
val configs = JsonObject().apply {
put(IMPORT_OPTION, "practitioners")
put(IMPORT_OPTION, "locations")
// put(SOURCE_FILE, "assets/locations.csv")
// put(USERS_FILE, "assets/users.csv")
// put(SKIP_USER_GROUP, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import io.vertx.kotlin.ext.web.client.webClientOptionsOf
import kotlinx.coroutines.launch
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import java.io.FileNotFoundException
import java.io.FileReader
import java.io.FileWriter
Expand All @@ -55,7 +55,7 @@ abstract class BaseVerticle : CoroutineVerticle() {

protected val deployedVerticleIds = mutableSetOf<String>()

protected val logger: Logger = LoggerFactory.getLogger(this::class.java)
protected val logger: Logger = LogManager.getLogger(this::class.java)

protected var limit = 50

Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="LOG_PATTERN">%d{HH:mm:ss.SSS} [%t] %highlight{%level}{FATAL=bg_red, ERROR=red, WARN=yellow,
INFO=green, DEBUG=blue} - %msg%n
</Property>
<Property name="FILE_LOG_PATTERN">%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %p %m%n</Property>
</Properties>

<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
<RollingFile name="infoLog"
fileName="logs/opensrp-data-import.log"
filePattern="logs/opensrp-data-import-%d{yyyy-MM-dd}-%i.log">
<LevelRangeFilter minLevel="INFO" maxLevel="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${FILE_LOG_PATTERN}"/>
<Policies>
<SizeBasedTriggeringPolicy size="20000KB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.smartregister.dataimport" additivity="false">
<AppenderRef ref="infoLog"/>
<AppenderRef ref="Console"/>
</Logger>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
27 changes: 0 additions & 27 deletions src/main/resources/logback.xml

This file was deleted.

0 comments on commit d499ca3

Please sign in to comment.