The following article was written by Karl-Heinz Kunzelmann as he researched how to write plugins for ImageJ2. It is reproduced here as a News post in the hope that it may help others, particularly during 2016 while the information continues to be most accurate and relevant.
编写 ImageJ2 插件:初学者的视角
序言
在您考虑为 ImageJ 编写自己的 plugin 之前,请注意,编写 script 的入门门槛比 Java 插件开发低得多。
此外,您可能还想看看Introduction_into_Macro_Programming,这是一种使用现有工具和插件自动执行重复任务的简单方法。
查找信息
- 顶级信息源是the ImageJ wiki。
- Development 页面是有抱负的 ImageJ 开发人员的最佳门户。
- ImageJ2 可在以下位置获取:imagej/imagej
- Fiji 可在以下位置获取:fiji/fiji
- 如需其他帮助,请使用ImageJ Forum。
搜索引擎会将您指向 imagej.net 和 developer.imagej.net。如今,请避免在任何事情上使用 §§§2§§§。这是一个遗留站点,正在被完全淘汰。如果您需要下载,请参阅Downloads页面。
配置您的环境
您将需要:
- 爪哇
- 强烈推荐IDE(例如:Eclipse、NetBeans或IntelliJ_IDEA)
- Git
- Apache Maven
- ImageJ2 source code是可选帮助
用于测试本指南的环境:
- Debian Jessie | macOS 10.14.x
- OpenJDK 1.8.x
- NetBeans IDE 版本 8.0.2 | IntelliJ IDEA 2019.2.2(社区版)
- git 2.x
- 阿帕奇Maven 3.x
Git 是一个具有修订控制功能的源代码管理系统。
Maven 是一个主要用于 Java 项目的构建自动化工具。
Git 和 Maven 都在上述 IDE 的当前版本中内置支持。
ImageJ wiki mentioned another software tool的早期版本,称为Jenkins,根据维基百科,它是“一个用 Java 编写的开源持续集成工具”。该工具后来被名为 Travis CI 的类似工作服务所取代。 Maven 和 Travis CI 等工具使得临时开发人员在开始时理解 ImageJ Plugin 开发的工作流程变得更加复杂。然而,这些工具由社区维护得很好,因此您最初不必考虑太多,并且它们有助于编程过程。例如,关于“Travis CI”,只要知道“持续集成”意味着每天多次将所有开发人员工作副本合并到共享主线就足够了。这里,多个开发人员的工作在一台机器上进行编译和测试,以确保组合的代码随时生成一个可工作的项目。对于开发供我们个人使用的单个插件,我们暂时可以忽略“Travis CI”。如果您想在 ImageJ 更新程序中共享您的插件,甚至为 ImageJ 项目做出贡献,这将非常重要。
所有source code都在GitHub上。由于 ImageJ 现在是一个相当复杂的项目,它的开发分为几个ImageJ subprojects。对于初学者来说,很难理解不同可用项目之间的交互,这些项目都在“SciJava”标签下为 ImageJ2 做出贡献。令人高兴的是,Maven 将借助 ImageJ2 开发者社区提供的配置文件自动从所有 ImageJ 子项目中提取必要的代码。 ImageJ wiki 提供了 ImageJ2 SciJava ecosystem 的第一个概述。
为了使 Maven 工作,我们需要所谓的 pom.xml 文件。这些配置文件包含有关项目的信息以及 Maven 用于构建项目的各种配置详细信息。 pom.xml 文件有助于组织构建 ImageJ 所需的一切。您可以通过该方法使用任何您想要的基于 Maven 的项目,而不仅仅是 ImageJ。所以例如您可以通过这种方式导入fiji/fiji,或者导入单个插件,例如fiji/AnalyzeSkeleton。
一般来说,有两种替代策略来开发插件:
- 在没有 Maven 的情况下使用 IDE
- 将 IDE 与 Maven 结合使用
在没有 Maven 的情况下使用 NetBeans
当您使用 IDE 构建自己的插件时,ImageJ 项目将作为预编译的 JAR 依赖项链接到所有插件(JAR 文件是 java 项目的存档)。
下载当前的 JAR 文件,例如imagej-2.0.0-SNAPSHOT-all.jar,您打算在本地项目中将其用作库。
您还可以使用 JAR 文件来编译您自己的插件,这些插件分布在 Fiji.app/plugins 目录中。
当您download Fiji时,请注意选择正确的 Fiji 版本。页面顶部最显着的下载选项是用 JDK 1.8 编译的,而您可以在页面底部下载所谓的“生命线”版本,这些版本是用 JDK 1.6 编译的,以确保与 ImageJ2 团队不支持的旧插件兼容。详细信息look here。
在任何情况下,您都需要打开一个新项目,指定项目名称、其目录位置并将 JAR 文件添加为库。
- File › New Project:Java 应用程序(项目名称、项目位置)
- 右键单击树视图中的项目window › Properties
- Libraries › Add JAR/Folder:指向您为 ImageJ/Fiji 下载的 JAR 文件。
有关如何使用较旧版本的 NetBeans(版本 6.7)(包括 build.xml 文件的一些自定义)的有点过时但相当详细的描述,请参见here。
Please consider:
Using JAR works for local development, but it will cause you various problems later. For example, if you share your source code, you will need to commit this JAR along with your NetBeans project files to your repository, to ensure everyone else uses the same version of ImageJ that you do.
使用 NetBeans、Git 和 Maven 构建 ImageJ
使用 Maven 开发插件是一种更好的方法。您不必将任何 JAR 文件提交到源代码管理。您可以将代码固定到其依赖项的固定已知版本,这些版本将在未来许多年内提供reproducible builds。
在 NetBeans 中获取 ImageJ 源应该像从 Git 存储库导入源一样简单。
以下内容改编自第Developing ImageJ in NetBeans页。
导入并构建项目:
- 运行 NetBeans
- 从 NetBeans 菜单中选择 Team › Git › Clone…
- 对于存储库 URL,输入:
https://github.com/fiji/fiji或输入https://github.com/imagej/imagej - 单击下一步,检查
master*分支,然后再次下一步,然后完成 - 出现提示时,单击“打开项目…”,如果出现错误消息,请单击“解决”。
启动程序:
- 展开“ImageJ Projects”项目,然后展开“Modules”
- 扩展“ImageJ POM:用户界面”模块
- 双击“ImageJ Application”项目将其打开
- 右键单击“ImageJ Application”项目并选择“运行”
- 在主类对话框中,选择“net.imagej.Main”
- 要展开项目,您还可以右键单击顶级“ImageJ 项目”并选择“打开所需项目”(以及“关闭所需项目”以关闭)。在开发过程中,您必须选择“打开所需项目”,然后才能在“打开项目”范围中成功执行“查找用法”。
不要期望在克隆imagej/imagej2或fiji/fiji后找到ImageJ源。
如果您想查看源代码来研究如何对图像分析算法进行编程,那么您将需要克隆其他 GitHub 项目。
Side note: I am not expert NetBeans user, therefore I could not figure out another way:
To import several projects from GitHub I always had to close all open project in NetBeans before I could import another project. If somebody knows a better way, please add here.
使用 IntelliJ IDEA、Git 和 Maven 构建 ImageJ 教程插件
设置 IntelliJ
- 确保您安装了 Java SDK 1.8.x 版本
- 安装 IntelliJ 时确保激活 Maven 和 Git 插件
- 但是这些插件可以随时在主设置中激活
导入并构建项目:
- 运行IntelliJ IDEA
- 从主菜单中选择File › New › Project from Version Control › Git
ImageJ 1.x 插件
- 对于存储库 URL,输入:
https://github.com/imagej/example-legacy-plugin.git并选择要存储项目的本地文件夹
ImageJ2 插件
- 对于存储库 URL,输入:
https://github.com/imagej/tutorials.git并选择要存储项目的本地文件夹
导入
- 单击“克隆”,所有源将被下载并作为新项目打开
- 如果 IntelliJ 要求导入所有 Maven 更改,您必须允许此操作
- 展开位于 IntelliJ 窗口边缘之一的 Maven 窗口,然后选择您的项目
- 在这里您可以右键单击并“运行 Maven Build”,或者在 Maven 窗口中按其上方的绿色箭头来构建您的项目
- 构建过程将在 [project_name]/targets/ 下生成两个
.jar文件,可以将其安装在本地 ImageJ 安装中
编写插件的详细信息
教程
- 对于 ImageJ 1.x:Introduction into Developing Plugins 和 Example Legacy Plugin
- 对于 ImageJ2:Writing plugins(注意:Writing plugins#Update_your_POM 中的指令“更新您的父 POM”仅意味着应调整版本号以反映 GitHub 上父 POM 文件的最新可用版本。)
- ImgLib2 Examples
- Developing ImgLib2
- ImageJ Ops
开始使用
从现有插件作为模板开始:
- 对于 ImageJ 1.x 插件:imagej/minimal-ij1-plugin
- 对于 ImageJ2 插件:simple-commands in imagej/tutorials
将其作为示例项目导入到您的 IDE 中,并根据您的需要修改该项目:
- NetBeans:File › Open Project
以下行是从 minimal-ij1-plugin 的 README.md 文件中复制/引用的:
- 编辑
pom.xml文件并更改- the
artifactId- Note: for ImageJ 1.x plugins the
artifactIdshould contain a_character. If you write an ImageJ2 command (like the ones linked above insimple-commandstutorial) then the underscore is unnecessary.
- Note: for ImageJ 1.x plugins the
- the
groupId- You should put a
groupId. It is misleading to leave it off, because thennet.imagej(orsc.fijiif you usedpom-fijias parent) will be inherited. And your project is probably not a core ImageJ project.
- You should put a
- the
version(note that you typically want to use a version number ending in-SNAPSHOTto mark it as a work in progress rather than a final version) - the
dependencies(read how to specify the correctgroupId/artifactId/versiontriplet here) - the
developerinformation - the
scminformation
- the
- 删除
Process_Pixels.java文件并将您自己的.java文件添加到src/main/java/<package>/中(如果您在生成的.jar文件中需要支持文件(例如图标),请将它们放入src/main/resources/中) - 编辑
src/main/resources/plugins.config- This is only needed for ImageJ 1.x plugins. For ImageJ2 commands, the information is provided by the
@Pluginannotation at the top of the Java class.
- This is only needed for ImageJ 1.x plugins. For ImageJ2 commands, the information is provided by the
- 将
README.md的内容替换为有关您的项目的信息。
其他示例插件
The imagej/tutorials are structured as individual projects. The files can live in a directory on its own outside the ImageJ or Fiji project. The pom.xml files of the imagej/tutorials pull in all the necessary dependencies for compiling via Maven.
“One file to bind them all”: parent pom.xml files
As the projects get more complex, read about the Maven component structure of ImageJ/SciJava and something which is called “Bill of Materials” or just BOM. A “BOM” is a list of dependencies at particular versions which are believed to be mutually compatible. The complexity of ImageJ/SciJava’s dependencies is a tribute to the different organizations which are contributing with their independent projects to ImageJ/SciJava. There are several “parent” pom.xml files which are independently maintained for example by the ImageJ, ImgLib2 or SCIFIO organizations. Each of these organizations has developed source code components which depend on components within the other two organizations. This complicated network of dependencies is managed with the help of the parent pom.xml files, i.e. pom-imagej, pom-fiji, pom-imglib2 etc. (see a list of all on the ImageJ Architecture page).
Initially I could not figure out where to put one of these pom-xxx files to use it as parent POM. I erroneously thought it should be downloaded from GitHub and copied somewhere in my ImageJ projects folders. However, one does not have to take care of the parent POM file at all! You just have to refer to it in the local pom.xml file of your intended plugin project in the section <parent>.
<parent>
<groupId>net.imagej</groupId>
<artifactId>pom-imagej</artifactId>
<version>15.1.0</version>
<relativePath />
</parent>
If pom-imagej is the parent POM file, then the local pom.xml could override the following configuration sections:
<name>
<description>
<url>
<inceptionYear>
<organization>
<licenses>
<developers>
<contributors>
<scm>
<issueManagement>
<ciManagement>
In the local pom.xml at least the sections:
<groupId>
<artifactId>
<version>
should be changed. Optionally also:
<name>
<description>
<url>
Finally add at least one of the following dependencies for ImageJ plugin support:
<dependencies>
// support for ImageJ2 plugins
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</dependency>
// support for ImageJ 1.x plugins
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>
</dependencies>
Further readings
- README.md of the Minimal Maven based ImageJ 1.x plugin
- Learn more about ImageJ/SciJava dependencies
- ImageJ Maven FAQ
Other References
- Git tutorial: Git in 15 min
- Web interface for git: GitHub
and all other links cited in the text!
Appendix
How do I find dependencies?
You can search by class for Maven artifacts. For example, search for ij.plugin.PlugIn. There is also a “Find Jar For Class” helper script in Fiji which does a similar thing for JAR files currently on ImageJ’s classpath.
If you are comfortable with command-line tools, you can also use the Maven Dependency Plugin which enables you to do things like download local copies of the dependency jars for inspection.
Also mvnrepository.com is a good resource to find repositories with code you can easily copy and paste in your pom.xml.
Manage Java versions
On Linux several java version can be installed. Select the preferred version in a terminal window (e.g. bash):
update-alternatives --config java
Note: It might be necessary to use sudo.
If necessary, tell NetBeans to use JDK 1.8 as the default JRE for new projects (i. e. on Debian Linux: Project Properties › Build › Compile… /usr/lib/jvm/java-1.8.0-openjdk-amd64) or alternatively set the netbeans_jdkhome property in your NetBeans config file. It should be in the local NetBeans directory, for example ./netbeans-8.0/netbeans.conf.
在哪里可以找到示例插件?
- ImageJ Tutorials
- In NetBeans: Team › Git › Clone
- Repository URL: https://github.com/imagej/tutorials
- Edit “destination” directory
- Next
- Select
master* - Next
- Finish
插件的目录结构是什么?
本文改编自 Maven 页面。
一个非常简单的演示项目的目录结构如下所示:
DemoPlugin
|-- pom.xml
|-- src
| !-- main
| |-- java
| | !-- MyPlugin.java
| !-- resources
| !-- sample-image.tif
编译 java 文件后,Maven 会自动生成 target 文件夹的内容。因此:切勿将 target 中的任何文件提交到 Git!您可以使用 .gitignore 文件告诉 Git 忽略这些文件(通常您首先从另一个项目复制an existing one)
!-- target
|-- classes
| |-- sample-image.tif
| |-- META-INF
| | !-- json
| | !-- org.scijava.plugin.Plugin
| !-- MyPlugin.class
|-- generated-sources
| !-- annotations
|-- maven-status
| !-- maven-compiler-plugin
| !-- compile
| !-- default-compile
| |-- createdFiles.lst
| !-- inputFiles.lst
!-- test-classes
一般来说:
将您的 .java 文件放在 src/main/java/ 下,并将您需要包含的其他文件放入 src/main/resources/ 下。
如果您想应用称为“回归测试”甚至“测试驱动开发”的最佳实践,请将测试的.java文件放入src/test/java/中,将您可能需要的非.java文件放入src/test/resources/中。
有关 Maven 标准目录布局的更多信息可以在 Maven website 上找到。
最小的 pom.xml 是什么样的?
本文改编自第Maven页。
这是一个非常简单的例子:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mywebsite</groupId>
<artifactId>my-uber-library</artifactId>
<version>2.0.0-SNAPSHOT</version>
</project>
前 6 行当然只是表达“嗨,Maven?你今天好吗?这就是我希望你做的……”。
唯一相关的部分是 groupId,按照惯例,它类似于反向域名(类似于 Java 包约定)、要构建的工件的名称(它将被放入 target/ 中,名称为 <artifactId>-<version>.jar)。当然还有版本。
虽然上面的示例pom.xml显示了总体思路,但对于 ImageJ 来说,必须考虑更多细节。因此,最好从现有的 pom.xml 文件开始,例如 imagej/minimal-ij1-plugin 中的文件。将其复制到您的项目并根据需要进行修改。
插件在 IJ 或 Fiji 中是否仍需要下划线才能可见?
如果您的插件是 ImageJ 1.x 样式插件,则需要下划线。即:它实现了 ij.plugin.PlugIn 或 ij.plugin.filter.PlugInFilter? 然后在 JAR 文件和/或类名中添加下划线。
如果您编写 ImageJ2 命令插件(即:使用 @Plugin 注释实现 org.scijava.command.Command 接口),则不再需要下划线。
让插件出现在菜单中
示例,设置 plugins.dir 属性,以便插件在从 IDE 启动时出现在菜单中:
仅 ImageJ 1.x 样式插件需要设置 plugins.dir。如果您编写 ImageJ2 命令,它无论如何都应该出现在菜单中。
NetBeans:Ant 和 Maven 有什么区别?或者:build.xml 与 pom.xml
Ant 主要是一个构建工具,这意味着它知道如何编译和打包源代码并运行测试,但没有能力管理项目依赖项。 Ant 使用 build.xml 文件来定义在哪里可以找到源代码以及构建项目需要采取哪些步骤。
Maven 不仅仅是一个构建工具,它还是一个项目管理工具。它允许您在
pom.xml项目定义中定义依赖项,以及构建、测试和分发应用程序。它还允许子项目、父项目,并且存在许多用于许多其他功能的插件。 Maven会自动下载依赖关系并管理项目之间的这些依赖关系。
Maven 是声明性的,而 Ant 是过程性的。在 Ant 中,您可以说“执行 X,然后执行 Y,然后执行 Z”。而在 Maven 中,你说“我的代码在这里,我的资源在那里,请使用这些插件”。后者的一个优点是 Maven 提供了标准化的构建顺序(称为“构建生命周期”),使其与所有主要 IDE 兼容。
如何将现有项目迁移到Maven项目?
在 Netbeans 中
- 备份您的项目。
- 创建一个名为
NewMavenProject的新项目。 - 关闭您的原始项目。
- 复制 imagej/minimal-ij1-plugin 中的
pom.xml或其他适当的模板。 - 修改
pom.xml的项目特定设置(例如项目名称、依赖项)。 - 删除
build.xml和整个nbproject文件夹。 - 将文件夹移动并重命名为
src/main/newproject(newproject是新名称)。 - 将
src/java移至src/main/java。 - 在 NetBeans 中再次打开您的项目。现在应该是一个 Maven 项目了。
- 删除不必要的
NewMavenProject项目。
在 IntelliJ IDEA 中
- 使用 File › New Project 创建一个新的 Maven 项目
- 选择左侧的Maven,然后单击下一步
- 选择您的自定义 GroupID(例如 com.yourwebsite)和 ArtifactID 作为该项目的单一标识符(例如 project_name)
- 请注意,对于 ImageJ 1.x 插件,项目名称/标识符中需要有一个“_” ImageJ 1.x 插件
- 将为您创建Maven所需的项目结构
- 对于 Git 支持(推荐):VCS › Import into Version Control › Git
- 将所有
.java文件复制到[project_name]/src/main/java - 将
plugins.config文件复制到 [project_name]/src/main/resources - 在主项目目录 [project_name]/ 中,您可以找到
pom.xml,必须像上一章中所示的示例一样对其进行编辑 - 如果您的 IDE 要求导入所有 Maven 更改,您必须允许此操作
- 展开位于 IntelliJ 窗口边缘之一的 Maven 窗口,然后选择您的项目
- 在这里,您可以右键单击并运行 Maven Build,或者在 Maven 窗口中按其上方的绿色箭头来构建您的项目
- 构建过程将在 [project_name]/targets/ 下生成两个
.jar文件启用 ImageJ 1.x UI,而不是 ImageJ2 Swing UI
将以下依赖项添加到您的 POM:
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-legacy</artifactId>
<scope>runtime</scope>
</dependency>
这将启用 ImageJ 1.x UI,而不是默认的 ImageJ2 Swing UI。
Java 6 和 Java 8 到底是怎么回事?
Java 6 与 Java 8 的当前情况以及对 Java 3D 的影响基本上是:
- 如果您从 Downloads 页面下载“vanilla”ImageJ2(作者注:在软件上下文中,“vanilla”是指按最初分发的方式使用的软件,没有对其应用任何自定义或更新),您将在 2016 年 2 月获得“Java 8”版本。
- 如果您download the latest Fiji,您将获得最新的“Java 8”版本,即带有 Java-8 更新站点。这包括 Java 3D 1.6(SciJava 分支)以及所有已更新以与其配合使用的 Fiji 插件(TrakEM2 除外)。
- 如果您download a Life-Line version of Fiji并完全更新它,您将拥有最新的(可能是最终的)“Java 6”版本,包括最新的 Java-6 兼容插件版本。在您第一次运行 3D Viewer 并自动安装之前,没有 Java 3D。这些插件版本已被冻结:ImageJ/Fiji 开发人员正在将所有内容迁移到 Java 8,并且现在仅将所有内容的新版本上传到 Java-8 更新站点,以避免破坏所有内容的稳定 Java-6 版本。
最终,ImageJ/Fiji 开发人员将把所有 Java-8 内容推回到 ImageJ 和 Fiji 核心站点。但直到 ImageJ/Fiji 开发人员添加启动检查来验证您的 Java 版本是否足够新,如果不够新,就会告诉您如何升级它。当 ImageJ/Fiji 开发人员完成该转换时,他们肯定会存档 ImageJ 和 Fiji 的最终 Java-6 兼容版本。
注意:您可以按照described here检查Java版本。
更多信息可以在这里阅读:2015-12-22 - The road to Java 8
从本地定制的 Fiji 制作可再发行包
将本地定制的 Fiji 转换为可再发行的软件包,然后可以安装在其他计算机上,例如:在您的实验室中:使用 Make Fiji Package 命令。
使用 JUnit5 进行测试
在 IntelliJ IDEA 中,您可能需要确保 JUnit5 插件已激活。下一步是将以下行附加到您的 pom.xml 文件中:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<build>
<plugins>
<plugin>
<!-- fix maven tests -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<excludes>
<exclude>some test to exclude here</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
If you want to test GUI tests with TravisCI you have to activate a virtual display as described in the Travis CI chapter.
Continuous Integration with Travis CI
If you want to share your plugin in the ImageJ updater automatically Automatic Update Site Uploads, contribute to the ImageJ project Fiji/Contribution requirements or work in a team with multiple developers, you may want to build, test and deploy your Plugin with Travis CI. If you are hosting your code in a public GitHub repository this service is free for you. After signing in with your GitHub account you can activate single repositories for Travis CI. Travis then automatically clones your repository with every change and runs a build according to the .travis.yml configuration file in your root directory.
# specify compiler
language: java
sudo: false # faster builds
jdk: openjdk8
# maven build
install: true
script: mvn clean verify
# cache maven dir for performance
cache:
directories:
- $HOME/.m2
In case you are working with GUI tests, you may want to activate a virtual display as well:
# virtual display variable for gui tests
dist: xenial
services:
- xvfb
JavaFX JAR not found
Add this to your pom.xml:
<build>
<plugins>
<!-- Fix JavaFX support -->
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>your.package.with.Launcher</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Log4j warning in IntelliJ IDEA
Some of the tutorials seem to be missing a configuration file for Log4. IntelliJ will warn you about this as soon as you try to try to build the project:
log4j:WARN No appenders could be found for logger (org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
The missing config file is called log4j.xml and has to be located in .../src/main/resources/:
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="demoApplication.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<root>
<priority value ="debug"></priority>
<appender-ref ref="fileAppender"></appender-ref>
</root>
</log4j:configuration>