This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace log4j by logback, other minor improvements
- Loading branch information
hainguyen
committed
Apr 25, 2015
1 parent
d767eb8
commit 098ebaa
Showing
23 changed files
with
318 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- For assistance related to logback-translator or configuration --> | ||
<!-- files in general, please contact the logback user mailing list --> | ||
<!-- at http://www.qos.ch/mailman/listinfo/logback-user --> | ||
<!-- --> | ||
<!-- For professional support please see --> | ||
<!-- http://www.qos.ch/shop/products/professionalSupport --> | ||
<!-- --> | ||
<configuration> | ||
<!-- Errors were reported during translation. --> | ||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<appender name="email" class="com.esofthead.mycollab.configuration.MailAppender"> | ||
<subject>Error: %logger{20} - %m</subject> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<pattern>%date %-5level %logger{35} - %message%n</pattern> | ||
</layout> | ||
</appender> | ||
<appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>logs/mycollab.out</file> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<!-- daily rollover --> | ||
<fileNamePattern>mycollab_%d{yyyy-MM-dd}.log</fileNamePattern> | ||
|
||
<!-- keep 30 days' worth of history --> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<logger name="org.springframework" level="INFO"></logger> | ||
<logger name="com.esofthead" level="INFO"/> | ||
<logger name="org.eclipse.jetty" level="INFO" /> | ||
<root level="INFO"> | ||
<appender-ref ref="stdout"/> | ||
<appender-ref ref="email"/> | ||
<appender-ref ref="R"/> | ||
</root> | ||
</configuration> |
33 changes: 0 additions & 33 deletions
33
mycollab-app-community/src/main/resources/log4j.properties
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
mycollab-config/src/main/java/com/esofthead/mycollab/configuration/LogConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* This file is part of mycollab-config. | ||
* | ||
* mycollab-config is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* mycollab-config is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with mycollab-config. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.esofthead.mycollab.configuration; | ||
|
||
import ch.qos.logback.classic.LoggerContext; | ||
import ch.qos.logback.classic.joran.JoranConfigurator; | ||
import com.esofthead.mycollab.core.utils.FileUtils; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* @author MyCollab Ltd | ||
* @since 5.0.5 | ||
*/ | ||
public class LogConfig { | ||
public static void initLog() { | ||
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); | ||
loggerContext.reset(); | ||
JoranConfigurator configurator = new JoranConfigurator(); | ||
InputStream inputStream = LogConfig.class.getClassLoader().getResourceAsStream("logback-test.xml"); | ||
if (inputStream == null) { | ||
try { | ||
File configFile = FileUtils.getDesireFile(System.getProperty("user.dir"), "conf/logback.xml", "src/main/conf/logback.xml"); | ||
if (configFile != null) inputStream = new FileInputStream(configFile); | ||
} catch (FileNotFoundException e) { | ||
inputStream = LogConfig.class.getClassLoader().getResourceAsStream("logback.xml"); | ||
} | ||
} | ||
|
||
try { | ||
|
||
configurator.setContext(loggerContext); | ||
configurator.doConfigure(inputStream); // loads logback file | ||
inputStream.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
mycollab-config/src/main/java/com/esofthead/mycollab/configuration/MailAppender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This file is part of mycollab-config. | ||
* | ||
* mycollab-config is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* mycollab-config is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with mycollab-config. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.esofthead.mycollab.configuration; | ||
|
||
import ch.qos.logback.classic.net.SMTPAppender; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* @author MyCollab Ltd | ||
* @since 5.0.5 | ||
*/ | ||
public class MailAppender extends SMTPAppender { | ||
|
||
@Override | ||
public void start() { | ||
EmailConfiguration conf = SiteConfiguration.getEmailConfiguration(); | ||
if (StringUtils.isBlank(conf.getHost())) { | ||
return; | ||
} | ||
|
||
this.setSMTPHost(conf.getHost()); | ||
this.setSMTPPort(conf.getPort()); | ||
this.setUsername(conf.getUser()); | ||
this.setPassword(conf.getPassword()); | ||
this.setSTARTTLS(conf.getIsTls()); | ||
this.setFrom(SiteConfiguration.getNoReplyEmail()); | ||
this.addTo(SiteConfiguration.getSendErrorEmail()); | ||
super.start(); | ||
} | ||
} |
Oops, something went wrong.