参数化log4j.properties以获取日志文件位置

时间:2019-07-04 09:51:06

标签: apache-spark pyspark log4j

想知道是否有一种方法可以将log4j.properties文件参数化为日志文件名,并将其作为参数提交给spark-submit。下面是我尝试配置的方法,但它不起作用。

            String path = HttpContext.Current.Server.MapPath("~/images"); //Path

            //Check if directory exist
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path); //Create directory if it doesn't exist
            }

            string imageName = "Documentation" + id + ".docx";

            //set the image path
            string imgPath = Path.Combine(path, imageName);
            byte[] imageBytes = Convert.FromBase64String(base64String);

            File.WriteAllBytes(imgPath, imageBytes);

            Word2Pdf objWordPDF = new Word2Pdf();
            object FromLocation = path+"\\"+imageName;
            string FileExtension = Path.GetExtension(imageName);
            string ChangeExtension = imageName.Replace(FileExtension, ".pdf");

            if (FileExtension == ".doc" || FileExtension == ".docx")
            {
                object ToLocation = path + "\\" + ChangeExtension;
                objWordPDF.InputLocation = FromLocation;
                objWordPDF.OutputLocation = ToLocation;
                objWordPDF.Word2PdfCOnversion();
            }


            return imageName;
        }
        catch (Exception ex)
        {
            return null;
        }

    }

0 个答案:

没有答案