将Logback添加到类路径时出错

将Logback添加到类路径时出错

问题描述:

每当我尝试在logback-examples中运行setClasspath.sh时,都会出现错误. 我的logset setClasspath.sh文件如下所示:

Whenever I try to run setClasspath.sh in logback-examples, I get an error. My logback setClasspath.sh file looks like this:

#!/bin/sh

##
# This script will add logback jars to your classpath.
##

LB_HOME=/home/darryl/logback

CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-classic-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-core-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/logback-examples-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/lib/slf4j-api-1.7.6.jar"

export CLASSPATH

echo $CLASSPATH

但是,当我运行它时,出现以下错误:

However, when I run it, I get the following error:

: not foundath.sh: 2: ./setClasspath.sh: 
: not foundath.sh: 6: ./setClasspath.sh: 
: not foundath.sh: 8: ./setClasspath.sh: 
: not foundath.sh: 13: ./setClasspath.sh: 
: bad variable name14: export: CLASSPATH

有人可以告诉我怎么了吗?

Could someone tell me what's wrong?

我下载并提取了最新的logback版本(logback-1.1.1.tar.bz2).该归档文件包含一个logback-examples/setClasspath.sh脚本,但是默认情况下该脚本不可执行.实际上,它没有可执行权限存储在tar归档文件中.我使用以下方式授予了它可执行权限:

I downloaded and extracted latest logback version (logback-1.1.1.tar.bz2). This archive contains a logback-examples/setClasspath.sh script but this script is not executable by default. Actually, it's not stored with executable permissions in tar archive. I gave it executable permissions using:

chmod +x setClasspath.sh

我运行了它,它抱怨在行尾返回回车. (奇数^ M个字符) 因此,此文件使用错误的换行格式(Windows格式\ r \ n而不是unix格式:\ n). 您只需要将此文件转换为Unix格式,然后尝试再次运行即可.在系统上安装dos2unix实用程序.供您参考,在debian或ubuntu上,您可以以root身份运行

I ran it and it complains about a carriage return at the end of line. (odd ^M character) Thus, this file uses wrong new line formats (windows format \r\n and not unix format: \n). You should just convert this file to unix format and try to run it again. Install dos2unix utility on your system. For your information, on debian or ubuntu, you can run this as root

apt-get install dos2unix

然后,作为标准用户,将文件从dos格式转换为unix/linux格式:

Then, as standard user, convert the file from dos format to unix/linux format:

dos2unix setClasspath.sh

您可能应该将这个小问题通知给回拨人员.

You should probably notify logback guys about this small issue.