| At line 1 changed 1 line. |
| Log4j를 사용하여 Tomcat 5.x로깅 설정하기 |
| !!AppFuse 1.8+ and JBoss 4.0.2 |
| At line 3 changed 1 line. |
| 알림 : 여기의 방법은 Tomcat에 log4j로깅을 셋팅하기 위한것이다. 당신의 애플리케이션은 해당 웹 애플리케이션만의 log4j.properties를 WEB-INF/classes디렉토리로 배치될수 있다. |
| ;:''Contributed by Ivan Coro (ivcoro at hotmail)'' |
| At line 5 changed 1 line. |
| $CATALINA_HOME/common/classes에 log4j.properties파일을 생성한다. |
| (1) 먼저, 당신은 appfuse배치 디렉토리 전체는 jboss배치 디렉토리로 복사할 필요가 있다. JBoss의 디폴트 배치 디렉토리는 "/server/default/deploy/"와 같은 것이다. 나는 디렉토리를 "appfuse.war"와 같은 형식으로 이름(.war로 끝나는 이름)을 바꿀 필요가 있다. 그렇게 하면 jboss는 에러없이 이것을 감지하고 재로딩할수 있다. |
| At line 7 added 2 lines. |
| (2) 다음, 당신은 jboss내 데이터소스를 설정할 필요가 있다. 이것을 하기 위해, 당신은 "appfuse-ds.xml"이라는 이름의 파일이 필요하고 이것을 당신의 배치된 애플리케이션 디렉토리와 같은 레벨(이를테면, /server/default/deploy/)의 JBoss의 "deploy" 디렉토리에 둘 필요가 있다. 이 파일의 내용은 다음과 같다. |
| |
| At line 8 changed 6 lines. |
| log4j.rootLogger=ERROR, R |
| log4j.appender.R=org.apache.log4j.DailyRollingFileAppender |
| log4j.appender.R.File=${catalina.home}/logs/tomcat.log |
| log4j.appender.R.DatePattern='.'yyyy-MM-dd |
| log4j.appender.R.layout=org.apache.log4j.PatternLayout |
| log4j.appender.R.layout.ConversionPattern={%p} %c{2} %x %m%n |
| <datasources> |
| <local-tx-datasource> |
| <jndi-name>jdbc/appfuse</jndi-name> |
| <connection-url>jdbc:mysql://localhost:3306/appfuse</connection-url> |
| <driver-class>com.mysql.jdbc.Driver</driver-class> |
| <user-name>test</user-name> |
| <password>test</password> |
| </local-tx-datasource> |
| </datasources> |
| At line 16 changed 1 line. |
| commons-logging.jar 와 log4j-1.2.9.jar을 $CATALINA_HOME/common/lib로 복사할 필요가 있다. 주의, 몇몇 참조문서에서는 $CATALINA_HOME/server/lib로 이 파일을 복사해야 한다고 말하고 있으나 나의 경우 common/lib로 복사하는 것이 잘 작동했다. |
| (3) 다음, 당신은 애플리케이션의 WEB-INF디렉토리내 넣을 "jboss-web.xml"이라는 이름의 파일을 생성할 필요가 있다. 이 파일은 jboss배치를 위해 필요하고, 파일의 내용은 다음과 같다. |
| At line 18 changed 1 line. |
| 그리고 나서, 당신의 애플리케이션 log4j.properties($APPFUSE_HOME/web/WEB-INF/classes)에 다음의 내용을 추가한다. |
| {{{ |
| <?xml version="1.0" encoding="UTF-8" ?> |
| <jboss-web> |
| <context-root>/appfuse</context-root> |
| <resource-ref> |
| <res-ref-name>jdbc/appfuse</res-ref-name> |
| <res-type>javax.sql.DataSource</res-type> |
| <jndi-name>java:jdbc/appfuse</jndi-name> |
| </resource-ref> |
| </jboss-web> |
| }}} |
| At line 35 added 14 lines. |
| %%note __NOTE:__ 만약 당신이 appfuse라는 이름의 디폴트 애플리케이션명을 사용하지 않는다면 appfuse라는 단어를 당신이 생성한 애플리케이션 인스턴스의 이름으로 변경할 필요가 있다. %% |
|
| (4) JBoss서비스 재시작하기 |
|
| 당신은 JBoss에 AppFuse를 자동으로 배치하는 방법을 보기 위해 [Ken Yee's blog|http://www.keysolutions.com/blogs/kenyee.nsf/d6plinks/KKYE-697VEH]를 볼 수도 있다. |
|
| !!AppFuse 1.7 and JBoss 3.x. |
|
| ;:''Contributed by [Rick Hightower|http://jroller.com/page/RickHigh].'' |
|
| !AppFuse Security |
|
| Setting up AppFuse security in JBoss I was surprise how easy it was. |
|
| At line 21 changed 4 lines. |
| # Suppress the tomcat logging whilst DEBUG is switched on |
| log4j.logger.org.apache.catalina.core=ERROR |
| log4j.logger.org.apache.catalina.session=ERROR |
| log4j.logger.org.apache.jasper.compiler=ERROR |
| <application-policy name = "appfuse"> |
| <authentication> |
| <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" |
| flag = "required"> |
| <module-option name = "dsJndiName">jdbc/mysql</module-option> |
| <module-option name = "principalsQuery"> |
| select password from app_user where username=? |
| </module-option> |
| <module-option name = "rolesQuery"> |
| select role_name, 'Roles' from user_role where username=? |
| </module-option> |
|
| </login-module> |
| </authentication> |
| </application-policy> |
| At line 27 changed 1 line. |
| 개발하는 동안, 당신은 root logger를 DEBUG로 셋팅한다. 그리고 나서 Tomcat로깅이 DEBUG로 셋팅이 되면, 당신은 Jasper컴파일러로부터 수천라인의 컴파일 추적메시지를 보게될것이다. |
| It took me less time to setup Security than it did for me to setup logging. (Which is a bit of a nightmare!) |
| At line 29 changed 1 line. |
| 물론, 특정 애플리케이션을 구별하여, 당신의 애플리케이션 log4j.properties ROOT로그 레벨을 WARN이나 ERROR로 유지하고 특정 애플리케이션을 위해 디버깅을 활성화한다.(이를테면, org.appfuse=DEBUG) |
| The above assumes you have a database driver mapped under jdbc/mysql. |
| At line 31 changed 1 line. |
| 노트: 만약 당신이 stdout으로 Tomcat로깅을 수행하길 원한다면, 당신의 $CATALINA_HOME/common/classes/log4j.properties파일은 다음과 같을것이다. |
| Create DS file as follows, and put it in the deploy dir: |
| (C:\tools\jboss-3.2.3\server\default\deploy/mysql-ds.xml) |
| At line 34 changed 1 line. |
| log4j.rootLogger=ERROR, stdout, TOMCAT |
| <datasources> |
| <local-tx-datasource> |
| <jndi-name>jdbc/mysql</jndi-name> |
| <connection-url>jdbc:mysql://localhost:3306/mysql</connection-url> |
| <driver-class>com.mysql.jdbc.Driver</driver-class> |
| <user-name>root</user-name> |
| <password></password> |
| </local-tx-datasource> |
| </datasources> |
| }}} |
| At line 36 changed 3 lines. |
| log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
| log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
| log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} - {%p} %c{2} Thread [%t]; %x %m%n |
| The login security stuff goes in the config directory of the server, e.g., C:\tools\jboss-3.2.3\server\default\conf\login-config.xml. |
| At line 40 changed 5 lines. |
| log4j.appender.TOMCAT=org.apache.log4j.DailyRollingFileAppender |
| log4j.appender.TOMCAT.File=${catalina.home}/logs/tomcat.log |
| log4j.appender.TOMCAT.DatePattern='.'yyyy-MM-dd |
| log4j.appender.TOMCAT.layout=org.apache.log4j.PatternLayout |
| log4j.appender.TOMCAT.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} - {%p} %c{2} Thread [%t]; %x %m%n |
| I attached the [login-config.xml] file. Note the name has to be the name of your war (appfuse.war = appfuse). In reality, it has to be the name of the web context, but since my web context and war file name are the same it works. |
| At line 90 added 18 lines. |
| [mysql-ds.xml] has to be in the deploy dir, e.g., C:\tools\jboss-3.2.3\server\default\deploy\mysql-ds.xml. |
|
| (The war file goes into the deploy dir as well). |
|
| !WARNING: |
|
| JBoss holds onto the cache of users and roles. So if you changed a users role, they would not be able to see it for 1/2 an hour. |
|
| I subclassed UserManagerImpl, and created a version specific to JBoss, then I changed UserManagerImpl to use a stub method called flushAuthCache. UserManagerJBossSpecific invalidates the user cache using JMX. JBoss is pretty cool! |
|
| Since I am using Spring. I did not have to change any other code in the system. Just one configuration file! |
|
| Spring change: |
|
| {{{ |
| <bean id="userManager" class="org.appfuse.webapp.service.UserManagerJBossSpecific"> |
| <property name="userDAO"><ref local="userDAO"/></property> |
| </bean> |
| At line 48 changed 1 line. |
| Tomcat 5에 대해서 좀더 많은 정보를 보기 위해서는 [Tomcat 5 Upgrade|Tomcat5Upgrade]를 보라. |
| [UserManagerJBossSpecific.java|http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3823134#3823134] |
| At line 50 changed 1 line. |
| Tomcat 5.5의 로깅에 대한 문서는 [Tomcat 5.5 Logging|http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html] 에서 볼수 있다. |
| !Logging |
| At line 52 changed 1 line. |
| 만약 당신이 위 지시사항으로 수행할수 없다면, tomcat내 두었던 파일들을 삭제하고 Tomcat을 commons로깅을 사용하도록 되돌릴것이다. |
| Setting up logging is a pain in JBoss. Don't mess with the console log... it misbehaves. Create a file logger and tail it. |
|
| Here is my [log4j.xml] file (which has to be in the conf dir like the login-config.xml). |
|
| I just tail -f the log file. |
|
| |