|
@@ -142,69 +142,25 @@ object ClientHolder {
|
|
|
class WebSocketEventListener {
|
|
|
@EventListener(ApplicationReadyEvent::class)
|
|
|
fun doSomethingAfterStartup() {
|
|
|
- Configurator.reconfigure(URI("http://127.0.0.1:9090/log-setting.xml"))
|
|
|
+ logBuilder()
|
|
|
}
|
|
|
|
|
|
- fun logBuilder(clNum: String) {
|
|
|
-// val builder = ConfigurationBuilderFactory.newConfigurationBuilder()
|
|
|
-// val consoleAppender = builder.newAppender("stdout", "Console")
|
|
|
-//
|
|
|
-// val appLog = builder.newAppender("appLog", "RollingFile")
|
|
|
-// appLog.addAttribute("fileName", "log/app/app.log")
|
|
|
-// appLog.addAttribute("filePattern", "log/app/\$\${date:yyyy - MM}/app-%d{yyyy-MM-dd}-%i.log.zip")
|
|
|
-//
|
|
|
-// val flow: FilterComponentBuilder = builder.newFilter(
|
|
|
-// "MarkerFilter",
|
|
|
-// Filter.Result.ACCEPT,
|
|
|
-// Filter.Result.DENY
|
|
|
-// )
|
|
|
-// flow.addAttribute("marker", "FLOW")
|
|
|
-// consoleAppender.add(flow)
|
|
|
-// val standard = builder.newLayout("PatternLayout")
|
|
|
-// standard.addAttribute("pattern", "%d %p [%c{1}] %m%n")
|
|
|
-// val policies = builder.newLayout("Policies")
|
|
|
-// val timeBasedTriggeringPolicy = builder.newLayout("TimeBasedTriggeringPolicy")
|
|
|
-// val sizeBasedTriggeringPolicy = builder.newLayout("SizeBasedTriggeringPolicy")
|
|
|
-//
|
|
|
-// sizeBasedTriggeringPolicy.addAttribute("size", "10 MB")
|
|
|
-// policies.addComponent(timeBasedTriggeringPolicy)
|
|
|
-// policies.addComponent(sizeBasedTriggeringPolicy)
|
|
|
-// consoleAppender.add(standard)
|
|
|
-// builder.add(consoleAppender)
|
|
|
-//
|
|
|
-// appLog.add(standard)
|
|
|
-// appLog.addComponent(policies)
|
|
|
-// builder.add(appLog)
|
|
|
-//
|
|
|
-// val rootLogger: RootLoggerComponentBuilder = builder.newRootLogger(Level.INFO)
|
|
|
-// rootLogger.add(builder.newAppenderRef("stdout"))
|
|
|
-// builder.add(rootLogger)
|
|
|
-//
|
|
|
-// val logger: LoggerComponentBuilder = builder.newLogger("co.id.datacomsolusindo.ipphonebridge", Level.DEBUG)
|
|
|
-// logger.add(builder.newAppenderRef("appLog"))
|
|
|
-// logger.addAttribute("additivity", false)
|
|
|
-// builder.add(logger)
|
|
|
-// rootLogger.add(builder.newAppenderRef("appLog"))
|
|
|
-//
|
|
|
-// ClientHolder.get().entries.forEach {
|
|
|
-// val clientLog = builder.newAppender("client-${it.key}", "RollingFile")
|
|
|
-// clientLog.addAttribute("fileName", "log/${it.key}/client-${it.key}.log")
|
|
|
-// clientLog.addAttribute(
|
|
|
-// "filePattern",
|
|
|
-// "log/${it.key}/\$\${date:yyyy - MM}/app-%d{yyyy-MM-dd}-%i.client-${it.key}.zip"
|
|
|
-// )
|
|
|
-// clientLog.add(standard)
|
|
|
-// clientLog.addComponent(policies)
|
|
|
-// builder.add(clientLog)
|
|
|
-//
|
|
|
-// val loggerClient: LoggerComponentBuilder = builder.newLogger("client-${it.key}", Level.DEBUG)
|
|
|
-// loggerClient.add(builder.newAppenderRef("client-${it.key}"))
|
|
|
-// loggerClient.addAttribute("additivity", false)
|
|
|
-// builder.add(loggerClient)
|
|
|
-// rootLogger.add(builder.newAppenderRef("client-${it.key}"))
|
|
|
-// }
|
|
|
+ fun logBuilder() {
|
|
|
+ val confFile = File("conf/general.ini")
|
|
|
+ var port = if (confFile.exists()) {
|
|
|
+ val ini = Wini(File("conf/general.ini"))
|
|
|
+ ini.get("server", "port")
|
|
|
+ } else {
|
|
|
+ System.getenv("PORT")
|
|
|
+ }
|
|
|
+ port = if (port == null) {
|
|
|
+// println("undefined port")
|
|
|
+ "9090"
|
|
|
+ } else {
|
|
|
+ port
|
|
|
+ }
|
|
|
|
|
|
- Configurator.reconfigure(URI("http://127.0.0.1:9090/log-setting.xml"))
|
|
|
+ Configurator.reconfigure(URI("http://127.0.0.1:$port/log-setting.xml"))
|
|
|
}
|
|
|
|
|
|
// @EventListener
|
|
@@ -250,7 +206,7 @@ class WebSocketEventListener {
|
|
|
)
|
|
|
|
|
|
LogManager.getLogger(this.javaClass).info("clientConnected $simDestination")
|
|
|
- logBuilder(clNum)
|
|
|
+ logBuilder()
|
|
|
LogManager.getLogger("client-$clNum").info("Client $clNum Connected")
|
|
|
}
|
|
|
}
|