以下這對話經常出現在我高中下課後
我:香草霜淇淋一個
店員:先生,請問你要什麼口味
我:…
我真的很想知道,你們聽到的是什麼
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production如果不理他其實也沒什麼影響,只是看久了也會難過,依以往用tomcat的經驗,就是download apr的source,再make install就好了,不過還是Google了一下,果然發現Ubuntu有自帶的package,還好沒做白工自己compile,然後就很開心的執行了下面的cmd
environments was not found on the java.library.path:
/usr/java/packages/lib/i386:/lib:/usr/lib:/usr/lib/jni
sudo apt-get install libtcnative-1再來就是重起tomcat6了。 暗,居然開不起來
Jul 24, 2009 3:22:12 PM org.apache.coyote.http11.Http11AprProtocol start SEVERE: Error starting endpoint java.lang.Exception: Socket bind failed: [22] Invalid argument at org.apache.tomcat.util.net.AprEndpoint.init(AprEndpoint.java:612) ..... at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)心理想,這是什麼東西....只好再拜請Google大神了。 修改 /etc/modprobe.d/aliases,找出
alias net-pf-10 ipv6改成
alias net-pf-10 off再重起電腦就OK。
------------------------------------------------------------------------------
【聶魯達一百首情詩-17】 聶魯達著/陳黎‧張芬齡譯
我愛你,但不把你當成玫瑰,或黃寶石,
或大火射出的康乃馨之箭。
我愛你,像愛戀某些陰暗的事物,
秘密地,介於陰影與靈魂之間。
我愛你,把你當成永不開花
但自身隱含花的光芒的植物;
因為你的愛,某種具體的香味
自大地升起,暗自生活於我的體內。
我愛你,不知該如何愛,何時愛,打哪兒愛起。
我對你的愛直截了當,不複雜也不傲慢;
我如是愛你,因為除此之外我不知道
還有什麼方式:我不存在之處,你也不存在,
如此親密,你擱在我胸前的手便是我的手,
如此親密,我入睡時你也闔上雙眼。
------------------------------------------------------------------------------
我想你明白,我會一直,往有你的地方走去。
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <appender name="SYSTEM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Prudent>true</Prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>%d{yyyy/MM/dd/}/System.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d [%thread] %-5level %logger{35} - %msg%n </Pattern> </layout> </appender> <appender name="MAIL" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Prudent>true</Prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>%d{yyyy/MM/dd/}/Mail.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%d [%thread] %-5level %logger{35} - %msg%n </Pattern> </layout> </appender> <root level="INFO"> <appender-ref ref="SYSTEM" /> <appender-ref ref="MAIL" /> </root> </configuration>
(1)要用Logback當然就一併用slf4j,Maven2的dependencies就加入:
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.16</version> <type>jar</type> </dependency> <!-- 用以取代commons-logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1.5.8</version> <type>jar</type> </dependency> <!-- 用以取代Log4j,若確定系統中都是透過commons-logging並未直接 呼叫log4j的話可以不用加此設定--> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>1.5.8</version> <type>jar</type> </dependency>
(2)logback-test.xml 與 logback.xml
Logback預設會先找classpath下是否有logback-test.xml,若沒有的話再找logback.xml,若都沒有就用預設的configuration.
所以如果是採用Maven預設的Source Code Structure的話,只要在src/test/resources/下放一個test專用的logback-test.xml就可以專門記錄test產生log.而不需要特別再去改正常系統的logback.xml.
(3)debug mode與automatically reloading
Logback有個機制可以檢視系統載入的logback configuration,還可以定時確認logback.xml是否有被改變而重新載入改變後的設定
<configuration debug="true" scan="true" scanPeriod="30 seconds"> </configuration>其中debug="true"就是開啟debug mode,會列出目前載入設定檔的名稱,裡面的logger,appender也會列出來。
(4)可以設定變數
1. 直接指定Properties name and value.
<property name="USER_HOME" value="/home/elliot" />2. 利用file指定properties file location
<property file="src/main/resources/system.properties" />3. 使用resource在classpath中找properties file
<property resource="system.properties" />就可以在logback.xml中使用${USER_HOME}來控制Log
(5)RollingFileAppender supports automatic file compression。
只要用FixedWindowRollingPolicy或TimeBasedRollingPolicy就可以自動壓縮。
<FileNamePattern>${namepattern}.log.zip/.gz</FileNamePattern>在FileNamePattern內最後加上.zip就會用zip壓縮,而加入gz即會使用gzip壓縮log.
(6)有趣的Filter
1. 可以利用LevelFilter只接收單一種類Level的Log
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter>這個Filter相當方便,有時在DEBUG時只希望看ERROR的部份,這個Filter可以讓我專注於ERROR的資料。
<filter class="ch.qos.logback.core.filter.EvaluatorFilter"> <evaluator name="myEval"> <expression>message.contains("billing")</expression> </evaluator> <OnMismatch>NEUTRAL</OnMismatch> <OnMatch>DENY</OnMatch> </filter>這個Filter也相當有用,當我希望取得具有特定字串或Exception的Log時,這個Filter能很方便的取得需要的資料。
西斯版為什麼好笑?請見範例,現在還是看一遍笑一遍啊
-----------------------------------
作者: ohyeahhh (古大熙) 看板: sex
標題: [心得] 近來西斯版的文章以往下了班就是隨便買點東西,開了Windows桌機就等WOW的登入畫面(我的WOW是放在Windows的啟動....羞)。
現在呢,下了班也是隨便買點東西,開了一台Ubuntu的桌機、一台Ubuntu的筆電跟一台Mac mini,然後就是LPIC跟Ruby交替看著,Mac mini就乖乖當著動物機跑。那這些有什麼好碎碎唸?
Ubuntu 9.04支援ext4,實在是頗快啊!而且常用到的Apache2, Tomcat6, Subversion 1.5.4,要設定的東西實在愈來愈少,東西做這麼好,我以後離不開怎麼辦,公司裡那台Red Hat Server實在想丟掉啊。
從開始用Ubuntu當Server,不再單純只當Coding的開發機,發現自己有很多的錯誤觀念,沒事自己在自己home folder建個java 目錄幹什麼,tomcat跟maven不用Ubuntu綁定的話就下載後丟到/opt下啊,沒事在.profile裡加PATH幹什麼,直接用ln -s加到/usr/bin下啊。Ubuntu要求一定要用sudo來做這些事其實很不錯,可以讓自己想清楚權限的事,Red Hat搞到最後幾乎都用root登入,實在很糟糕啊(是我糟糕不是Red Hat)。
其他要唸的像是:
Valen Hsu的新專輯有點給他失望,雖說不是第一次失望,但之前那首單曲“好聽“實在不錯啊,總覺得後面2張專輯詞曲都不是很優。真想聽Valen唱唱郭靜的“心牆“…倒底最近還有什麼新專輯可以聽的?
Springframework 3停在M3很久了,說好的RC呢?已經延了一個多月了耶,是不是要喝下每朝啊?不然M這麼久也該看醫生吧。
西斯不西斯很久了,快點開版啊!鄉民快不行了吧!
2台Ubuntu,1台Mac mini,那…我那台比前面3台加起來總價還貴的MBP呢?有了iPod Touch,我會沒事開它來聽音樂嗎(誤)?
最後
Elliot@iPhone coming soon!
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <execution> <phase>initialize</phase> <configuration> <tasks> <echo>basedir:${basedir}</echo> <echo>project.name:${project.name}</echo> <echo>project.version:${project.version}</echo> <echo>project.packaging:${project.packaging}</echo> <echo>project.build.finalName:${project.build.finalName}</echo> <echo>project.build.directory:${project.build.directory}</echo> <echo>project.build.outputDirectory:${project.build.outputDirectory}</echo> <echo>env.M2_HOME:${env.M2_HOME}</echo> <echo>env.CLICOLOR:${env.CLICOLOR}</echo> <echo>settings.localRepository:${settings.localRepository}</echo> <echo>java.home:${java.home}</echo> <echo>java.version:${java.version}</echo> <echo>java.vendor:${java.vendor}</echo> <echo>os.name:${os.name}</echo> <echo>os.arch:${os.arch}</echo> <echo>os.version:${os.version}</echo> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>自行修改<tasks>中的<echo> task成你要的,然後只要執行
>$ mvn initialize就可以看到結果囉。
用Maven建立Eclipse Project其實頗為容易,第一步用plugin: archetype建立Maven Project,第二步再用plugin: eclipse建立Eclipse要用的設定檔,再來用Eclipse import即可。
1. run mvn archetype:generate>$ mvn archetype:generate [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: local -> sampleweb-archetype (sampleweb-archetype) 2: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF) ......... 16: internal -> maven-archetype-quickstart () 17: internal -> maven-archetype-site-simple (A simple site generation project) 18: internal -> maven-archetype-site (A more complex site project) 19: internal -> maven-archetype-webapp (A simple Java web application) .......... 41: internal -> gmaven-archetype-basic (Groovy basic archetype) 42: internal -> gmaven-archetype-mojo (Groovy mojo archetype) Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42) 16: :
可以見到洋洋灑灑42個Template給你選,若沒合意的就用預設16來建吧。
[INFO] artifact org.apache.maven.archetypes:maven-archetype-quickstart: checking for updates from central Define value for groupId: : org.elliot.web Define value for artifactId: : test Define value for version: 1.0-SNAPSHOT: : Define value for package: org.elliot.web: : Confirm properties configuration: groupId: org.elliot.web artifactId: test version: 1.0-SNAPSHOT package: org.elliot.web Y: : y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating OldArchetype: maven-archetype-quickstart:RELEASE [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: org.elliot.web [INFO] Parameter: packageName, Value: org.elliot.web [INFO] Parameter: package, Value: org.elliot.web [INFO] Parameter: artifactId, Value: test [INFO] Parameter: basedir, Value: /Users/elliot/Documents/workspacetesting [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] ********************* End of debug info from resources from generated POM *********************** [INFO] OldArchetype created in dir: /Users/elliot/Documents/workspacetesting/test [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------
Maven要求你輸入groupId, artifactId, version, package後就會依你指定的artifactId建立一個Project。
>$ cd test >$mvn eclipse:eclipse [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'eclipse'. [INFO] ------------------------------------------------------------------------ [INFO] Building test [INFO] task-segment: [eclipse:eclipse] [INFO] ------------------------------------------------------------------------ [INFO] Preparing eclipse:eclipse [INFO] No goals needed for project - skipping [INFO] [eclipse:eclipse {execution: default-cli}] [INFO] Using as WTP server : null [INFO] Adding default classpath contaigner: org.eclipse.jdt.launching.JRE_CONTAINER [INFO] Using source status cache: /Users/elliot/Documents/workspacetesting/test/target/mvn-eclipse-cache.properties [INFO] Not writing settings - defaults suffice [INFO] Wrote Eclipse project for "test" to /Users/elliot/Documents/workspacetesting/test. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------
再import至Eclipse即可
>$ mvn eclipse:m2eclipse [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'eclipse'. [INFO] ------------------------------------------------------------------------ [INFO] Building test [INFO] task-segment: [eclipse:m2eclipse] [INFO] ------------------------------------------------------------------------ [INFO] Preparing eclipse:m2eclipse [INFO] No goals needed for project - skipping [INFO] [eclipse:m2eclipse {execution: default-cli}] [INFO] Using source status cache: /Users/elliot/Documents/workspacetesting/test/target/mvn-eclipse-cache.properties [INFO] Using as WTP server : null [INFO] Not writing settings - defaults suffice [INFO] Wrote Eclipse project for "test" to /Users/elliot/Documents/workspacetesting/test. [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------
一樣,import至Eclipse即可
使用Maven久了之後會發現,上列的方式仍有不便,例如Source Code Structure不符你的需求,相關的Plugin及Dependencies都需要一再加入pom.xml中,所以會希望能建立一個自己常用的範本。這時,你需要用的是archetype:create-from-project,然後將該archetype install到你Maven的repository中。簡單來說,用你現有的Project建立一個Template,之後再執行archetype:generate時再選擇你的template即可。
4. run mvn archetype:create-from-project>$ mvn archetype:create-from-project [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building test [INFO] task-segment: [archetype:create-from-project] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:create-from-project [INFO] ------------------------------------------------------------------------ [INFO] Building test [INFO] ------------------------------------------------------------------------ [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:create-from-project {execution: default-cli}] [INFO] Setting default groupId: org.elliot.web [INFO] Setting default artifactId: test [INFO] Setting default version: 1.0-SNAPSHOT [INFO] Setting default package: org.elliot.web [INFO] Archetype created in target/generated-sources/archetype [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------
Maven會將archetype範本產生在target/generated-sources/archetype目錄下,如果還有需要可以進到該目錄,若沒問題的下可以進行下一步
>$ cd target/generated-sources/archetype/ >$ mvn install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building test-archetype [INFO] task-segment: [install] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 7 resources [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Users/elliot/Documents/workspacetesting/test/target/generated-sources/archetype/src/test/resources [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:jar {execution: default-jar}] [INFO] [archetype:add-archetype-metadata {execution: default-add-archetype-metadata}] [INFO] [archetype:integration-test {execution: default-integration-test}] [INFO] [install:install {execution: default-install}] [INFO] Installing /Users/elliot/Documents/workspacetesting/test/target/generated-sources/archetype/target/test-archetype-1.0-SNAPSHOT.jar to /Users/elliot/.m2/repository/org/elliot/web/test-archetype/1.0-SNAPSHOT/test-archetype-1.0-SNAPSHOT.jar [INFO] [archetype:update-local-catalog {execution: default-update-local-catalog}] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------6. run mvn archetype:generate -DarchetypeCatalog=local
>$ mvn archetype:generate -DarchetypeCatalog=local [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: local -> sampleweb-archetype (sampleweb-archetype) 2: local -> test-archetype (test-archetype) Choose a number: (1/2):
這時就能看到剛才加入的Template供選擇了囉!
>$ mvn test-compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Maven [INFO] task-segment: [test-compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Users/elliot/Documents/workspacetesting/test/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] No sources to compile [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Users/elliot/Documents/workspacetesting/test/src/test/resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] No sources to compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------maven認出test-compile是一個Phase,所以執行了排在test-compile之前的Phase,
>$ mvn compiler:testCompile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Maven [INFO] task-segment: [compiler:testCompile] [INFO] ------------------------------------------------------------------------ [INFO] [compiler:testCompile {execution: default-cli}] [INFO] No sources to compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------Maven認出這是一個Goal所以只執行了compiler:testCompile就結束,並未執行其他的Goals。