Received: by 10.68.222.225 with SMTP id qp1mr32564pbc.8.1346199035327; Tue, 28 Aug 2012 17:10:35 -0700 (PDT) Received: by 10.68.233.5 with SMTP id ts5mr34207pbc.20.1346199035312; Tue, 28 Aug 2012 17:10:35 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!4no23964083pbn.1!news-out.google.com!a8ni89864317pbd.1!nntp.google.com!4no23964073pbn.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Tue, 28 Aug 2012 17:10:35 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: trying to redirect both std out and err to a file together and still err to a separate file From: Lew Injection-Date: Wed, 29 Aug 2012 00:10:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:18375 (unknown) wrote: > I tested your suggestion with some java [sic] code and it works nicely Whose suggestion about what? > comp.unix.shell: trying to redirect both std out and err to a file toget= her > and still err to a separate file =20 This is easy to do with shell constructs. > import java.util.Locale; > import java.util.Date; > import java.text.DateFormat; > =20 > // __=20 >=20 > public class Test{ >=20 > public static void main(String[] args){ > DateFormat DF =3D DateFormat.getDateInstance(DateFormat.FULL, Locale.FR= ANCE); http://www.oracle.com/technetwork/java/codeconv-138413.html You should follow the coding conventions, at least mostly. > // __ std out > System.out.println("// __ out.println: |" + DF.format(new Date()) + "|"= ); What are you trying to accomplish here? > DF =3D DateFormat.getDateInstance(DateFormat.FULL, Locale.CHINESE); >=20 > // __ std err >=20 > System.err.println("// __ err.println: |" + DF.format(new Date()) + "|"= ); >=20 > // __ Exception in thread "main" java.lang.NullPointerException >=20 > DF =3D null; > DF.format(new Date()); What are you trying to accomplish here? > } > } >=20 > /* > rm -f *.log >=20 > export _DT=3D`date +%Y%m%d%H%M%S_%s` > echo ${_DT} >=20 > (javac Test.java 2>&1 >&3 | tee ${_DT}"_errc.log" >&3) 3> ${_DT}"_errc.lo= g" Your use of quotation marks here is superfluous. I would have to review this shell command, but it looks weird=20 to me. I don't normally go for such outr=E9 file-descriptor manipulation=20 so it will take time and effort to sort all that stuff out. > (java Test 2>&1 >&3 | tee ${_DT}"_err.log" >&3) 3> ${_DT}"_err_out.log" >=20 > ls -l *.log > cat *_err.log > cat *_err_out.log > */ Glad it did what you want, though, whatever that was. Hard to tell when the message is not in its thread context. --=20 Lew