From log4j-user-return-28988-archive-asf-public=cust-asf.ponee.io@logging.apache.org Fri Jul 6 20:26:40 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E5F1E180674 for ; Fri, 6 Jul 2018 20:26:39 +0200 (CEST) Received: (qmail 22914 invoked by uid 500); 6 Jul 2018 18:26:38 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 22903 invoked by uid 99); 6 Jul 2018 18:26:38 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jul 2018 18:26:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 586CAC60A1 for ; Fri, 6 Jul 2018 18:26:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.799 X-Spam-Level: ** X-Spam-Status: No, score=2.799 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=1.5, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id k6lI9Ptt_YnN for ; Fri, 6 Jul 2018 18:26:36 +0000 (UTC) Received: from smtp475.redcondor.net (smtp475.redcondor.net [208.80.204.75]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id DF0375F2C5 for ; Fri, 6 Jul 2018 18:26:35 +0000 (UTC) Received: from mailproxy13.neonova.net ([137.118.22.78]) by smtp475.redcondor.net ({096fa88a-70b2-40e7-9c10-71504124e555}) via TCP (outbound) with ESMTP id 20180706182625297_0475 for ; Fri, 06 Jul 2018 18:26:25 +0000 X-RC-FROM: X-RC-RCPT: Received: from [10.9.100.161] (unknown [208.93.128.118]) (Authenticated sender: ralph.goers@dslextreme.com) by mailproxy13.neonova.net (Postfix) with ESMTPA id 125353611D7 for ; Fri, 6 Jul 2018 14:26:20 -0400 (EDT) From: Ralph Goers Content-Type: multipart/alternative; boundary="Apple-Mail=_1CB09B52-D1D6-4286-A353-8451D6B746EE" Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\)) Subject: Re: Odd problem starting program with log4j2 on Windows Date: Fri, 6 Jul 2018 11:26:19 -0700 References: <8ae9dfec-5875-9b9b-156a-b22bea4e100e@elyograg.org> <5BEF0CA4-A0F1-494C-9265-1D62D23B5CF4@dslextreme.com> <2D234518-48BA-4600-863D-BCFFBA359C9B@gmail.com> <15945d43-4768-2686-2892-c317489e2654@elyograg.org> To: Log4J Users List In-Reply-To: <15945d43-4768-2686-2892-c317489e2654@elyograg.org> Message-Id: X-Mailer: Apple Mail (2.3445.8.2) X-DLP-OUTBOUND: 137.118.22.64/27 X-MAG-OUTBOUND: greymail.redcondor.net@137.118.22.64/27 --Apple-Mail=_1CB09B52-D1D6-4286-A353-8451D6B746EE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Here is the entirety of the logic for Log4j 1 try { url =3D new URL(configurationOptionStr); } catch (MalformedURLException ex) { // so, resource is not a URL: // attempt to get the resource from the class path url =3D Loader.getResource(configurationOptionStr);=20 } The main difference I see is that Log4j 2 tries to create a URI and only = tries to create a URL if creating the URI throws an exception.=20 I=E2=80=99m all for switching to NIO2 if it provides an easier way to = find the file from all the various places it could be. Ralph > On Jul 6, 2018, at 10:50 AM, Shawn Heisey wrote: >=20 > On 7/5/2018 8:34 PM, Remko Popma wrote: >> I found that the problem can be reproduced with this: >>=20 >> new File(=E2=80=9Cfile:C:\\temp\\some.file=E2=80=9D).toURI() >>=20 >> If you print the above it shows: >>=20 >> file:/C:/my/current/directory/file:C:/temp/some.file >>=20 >>=20 >> So, the configuration should not prefix the path with =E2=80=9Cfile:=E2= =80=9D, but with =E2=80=9Cfile:/=E2=80=9C (slash after the colon). >=20 > Thanks to everyone who has replied, the discussion is valuable to me. >=20 > If I add //, it works with absolute paths on log4j2 when running on > Windows. I haven't checked Linux, but I suspect it would work there = too. >=20 > But the URI without // works on Linux in log4j2. I haven't tested, = but > I think that I would be able to use a relative path on Linux with the > "file:" prefix. >=20 > The file: URI without // works on both Linux AND Windows in log4j 1.x.=20= > I can use relative paths with either OS when using log4j 1.x. = Something > has changed from log4j 1.x to 2.x, something that works without = problems > on Linux but breaks on Windows. I think it's been well demonstrated > that the problem is in Java, not log4j. >=20 > For fixing the problem in Solr on Windows, I see two possibilities: >=20 > One fix (which I know works) is to abandon the file: prefix entirely.=20= > In the Solr startup script, the location is an absolute path. But I = do > have some worries that this might break in a future version. In = log4j > 1.x the "file:" prefix appears to be mandatory -- if I remove it from > the log4j.configuration system property, my logging configuration = isn't > found. With log4j 2.x, the system property is different -- > log4j.configurationFile instead of log4j.configuration ... which > suggests that URI syntax won't be required. >=20 > The other fix is to add slashes after file: ... but I'm not sure = whether > it should be two slashes or three slashes. Experiments with > Path#toUri() suggest that three slashes might be the preferred = canonical > form, but I'd like to know for sure. Two slashes does appear to work > with log4j. >=20 > Tangent: Has there been any desire in the project to abandon the File > object and switch to NIO2? Lucene made that plunge a while back. = I've > heard that it's a much better API. >=20 > Experiments with 'new URI(string)' seem to indicate that log4j (both = 1.x > and 2.x) accepts URI variations that are not allowed by the URI = object.=20 > A prefix of "file://" with a Windows path isn't allowed -- it requires > "file:///" to work. Because the Windows command shell provides paths > with backlashes, it would be difficult to specify a completely valid = URI > -- backslashes do not appear to be allowed in strict syntax. >=20 > Thanks, > Shawn >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-user-help@logging.apache.org >=20 >=20 --Apple-Mail=_1CB09B52-D1D6-4286-A353-8451D6B746EE--