原文网址:http://www.cnblogs.com/stonefeng/p/5767762.html
现象
不知道从哪个版本的tomcat开始,windows版本的tomcat不再包含{tomcat_home}\logs\catalina.out这个文件,eclipse中配置好tomcat服务器之后,日志都是在eclipse中的console中打印的,但是这样不方便看日志,因为每次服务器重启之后,eclipse会首先显示console视图然后自动跳转到servers视图,要看日志还得再选择console视图,而且console日志的窗口比较小,有异常打印出来的话要滚好几屏才能看到错误的根源。
问题
那么我们如何把eclipse中的tomcat日志分离出来呢?
解决方案
我们可以使用如下步骤来解决这个问题:
- 在eclipse的servers视图中双击tomcat服务器
id="iframe_0.7872251192923805" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i.imgur.com/NVEDpTc.png?_=5767762%22%20style=%22border:none;max-width:1022px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7872251192923805',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; width: 491px; height: 76px;">
- 点击Open launch configuration链接
id="iframe_0.5743313902655796" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i.imgur.com/pQebmF7.png?_=5767762%22%20style=%22border:none;max-width:1022px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5743313902655796',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; width: 801px; height: 256px;">
-
选择Common选项卡
-
勾选File勾选框并指定文件地址
id="iframe_0.5813216792976468" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i.imgur.com/jrhSt6L.png?_=5767762%22%20style=%22border:none;max-width:1022px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5813216792976468',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; width: 609px; height: 448px;">
- 重启服务器
最后
在上面的例子中我在{tomcat_home}\logs下面新建了catalina.out这个文件并使用了该文件,现在你可以像使用linux版本的tomcat一样,用第三方日志工具来打开这个文件了,我使用的是LogExpert,一个免费的非商业软件。
id="iframe_0.778726299754569" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i.imgur.com/mKSWvlQ.png?_=5767762%22%20style=%22border:none;max-width:1022px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.778726299754569',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; width: 1022px; height: 551px;">
第一次使用MarkDown语言写博客,有什么表述不清楚的地方还请大家海涵。