Fix some logging to write to file instead of stdout.

Change-Id: I3ea5449aee7d9683017cd03ab3e61d03c9b5bc82
diff --git a/Changes b/Changes
index f94d096..243bb0d 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@
 - Remove corpusQuery param in the statistics web-service (close #758).
 - Moved NamedVCLoader to the init package.
 - Clean up Spring XML configs.
+- Fix some logging to write to file instead of stdout.
 
 # version 0.73.2
 
diff --git a/src/main/java/de/ids_mannheim/korap/authentication/LdapAuth3.java b/src/main/java/de/ids_mannheim/korap/authentication/LdapAuth3.java
index 845a6d5..03c4a5d 100644
--- a/src/main/java/de/ids_mannheim/korap/authentication/LdapAuth3.java
+++ b/src/main/java/de/ids_mannheim/korap/authentication/LdapAuth3.java
@@ -192,7 +192,10 @@
                 System.out.print("Binding: OK.\n");
         }
         catch (LDAPException e) {
-            System.err.printf("Error: login: Binding failed: '%s'!\n", e);
+//            System.err.printf("Error: login: Binding failed: '%s'!\n", e);
+            String error = String.format("Error: login: Binding failed: "
+                    + "'%s'!\n", e);
+            jlog.error(error);
             ldapTerminate(lc);
             return new LdapAuth3Result(null, LDAP_AUTH_RINTERR);
         }
@@ -246,7 +249,10 @@
                 }
             }
             catch (LDAPException e) {
-                System.err.printf("Error: login: Binding failed: '%s'!\n", e);
+//                System.err.printf("Error: login: Binding failed: '%s'!\n", e);
+                String error = String.format("Error: login: Binding failed: "
+                        + "'%s'!\n", e);
+                jlog.error(error);
                 ldapTerminate(lc);
                 return new LdapAuth3Result(null, LDAP_AUTH_RUNKNOWN);
             }
diff --git a/src/main/resources/log4j2.properties b/src/main/resources/log4j2.properties
index dabe381..1201846 100644
--- a/src/main/resources/log4j2.properties
+++ b/src/main/resources/log4j2.properties
@@ -1,5 +1,5 @@
-#appenders = console, file, ldapFile
-appenders = console, file
+appenders = console, file, ldapFile
+#appenders = console, file
 appender.console.type = Console
 appender.console.name = STDOUT
 appender.console.layout.type = PatternLayout
@@ -11,11 +11,11 @@
 appender.file.layout.type=PatternLayout
 appender.file.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
 
-#appender.ldapFile.type = File
-#appender.ldapFile.name = LDAP_LOG
-#appender.ldapFile.fileName=./data/logs/ldap.log
-#appender.ldapFile.layout.type=PatternLayout
-#appender.ldapFile.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+appender.ldapFile.type = File
+appender.ldapFile.name = LDAP_LOG
+appender.ldapFile.fileName=./data/logs/ldap.log
+appender.ldapFile.layout.type=PatternLayout
+appender.ldapFile.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
 
 
 rootLogger.level = warn
@@ -23,23 +23,28 @@
 rootLogger.appenderRef.file.ref = MAINLOG
 rootLogger.additivity=true
 
-loggers=file
+loggers=file, auth, ldap
 logger.file.name=de.ids_mannheim.korap
 logger.file.level = info
 logger.file.appenderRefs = file
 logger.file.appenderRef.file.ref = MAINLOG
 logger.file.additivity=false
 
-loggers=file
-logger.console.name=de.ids_mannheim.korap.web.controller.AuthenticationController
-logger.console.level = warn
-logger.console.appenderRefs = file
-logger.console.appenderRef.file.ref = MAINLOG
-logger.console.additivity=false
-
 #loggers=file
-#logger.file.name=de.ids_mannheim.korap.authentication.LdapAuth3
-#logger.file.level = info
-#logger.file.appenderRefs = file
-#logger.file.appenderRef.file.ref = LDAP_LOG
-#logger.file.additivity=false
\ No newline at end of file
+#logger.console.name=de.ids_mannheim.korap.web.controller.AuthenticationController
+#logger.console.level = warn
+#logger.console.appenderRefs = file
+#logger.console.appenderRef.file.ref = MAINLOG
+#logger.console.additivity=false
+
+logger.auth.name=de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager
+logger.auth.level = error
+logger.auth.appenderRefs = file
+logger.auth.appenderRef.file.ref = LDAP_LOG
+logger.auth.additivity=false
+
+logger.ldap.name=de.ids_mannheim.korap.authentication.LdapAuth3
+logger.ldap.level = info
+logger.ldap.appenderRefs = file
+logger.ldap.appenderRef.file.ref = LDAP_LOG
+logger.ldap.additivity=false
\ No newline at end of file
diff --git a/src/test/resources/log4j2-test.properties b/src/test/resources/log4j2-test.properties
index f9b8a98..186ab06 100644
--- a/src/test/resources/log4j2-test.properties
+++ b/src/test/resources/log4j2-test.properties
@@ -1,14 +1,14 @@
-appenders = console,ldapFile
+appenders = console, file,ldapFile
 appender.console.type = Console
 appender.console.name = STDOUT
 appender.console.layout.type = PatternLayout
 appender.console.layout.pattern = %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
 
-#appender.file.type = File
-#appender.file.name = ERRORLOG
-#appender.file.fileName=./data/logs/errors.log
-#appender.file.layout.type=PatternLayout
-#appender.file.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+appender.file.type = File
+appender.file.name = MAIN_LOG
+appender.file.fileName=./data/logs/kustvakt.log
+appender.file.layout.type=PatternLayout
+appender.file.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
 
 appender.ldapFile.type = File
 appender.ldapFile.name = LDAP_LOG
@@ -20,6 +20,7 @@
 rootLogger.appenderRefs = console
 rootLogger.appenderRef.stdout.ref = STDOUT
 
+loggers=hibernate,auth,ldap
 #loggers=console
 #logger.console.name=com.sun.jersey.test.framework.spi.container
 #logger.console.level = info
@@ -34,23 +35,21 @@
 #logger.file.appenderRef.file.ref = ERRORLOG
 #logger.file.additivity=false
 
-loggers=console
-logger.console.name=org.hibernate
-logger.console.level = fatal
-logger.console.appenderRefs = stdout
-logger.console.appenderRef.file.ref = STDOUT
-logger.console.additivity=false
 
-loggers=console
-logger.console.name=de.ids_mannheim.korap.web.controller.AuthenticationController
-logger.console.level = warn
-logger.console.appenderRefs = stdout
-logger.console.appenderRef.file.ref = STDOUT
-logger.console.additivity=false
+logger.hibernate.name=org.hibernate
+logger.hibernate.level = error
+logger.hibernate.appenderRefs = file
+logger.hibernate.appenderRef.file.ref = MAIN_LOG
+logger.hibernate.additivity=false
 
-loggers=file
-logger.file.name=de.ids_mannheim.korap.authentication.LdapAuth3
-logger.file.level = info
-logger.file.appenderRefs = file
-logger.file.appenderRef.file.ref = LDAP_LOG
-logger.file.additivity=false
\ No newline at end of file
+logger.auth.name=de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager
+logger.auth.level = error
+logger.auth.appenderRefs = file
+logger.auth.appenderRef.file.ref = LDAP_LOG
+logger.auth.additivity=false
+
+logger.ldap.name=de.ids_mannheim.korap.authentication.LdapAuth3
+logger.ldap.level = info
+logger.ldap.appenderRefs = file
+logger.ldap.appenderRef.file.ref = LDAP_LOG
+logger.ldap.additivity=false
\ No newline at end of file